Make httpbin tests run when frozen.
This commit is contained in:
parent
fbf9c74752
commit
2cb1f9226a
@ -30,6 +30,8 @@ import cx_Freeze as cx # pylint: disable=import-error
|
|||||||
# cx_Freeze is hard to install (needs C extensions) so we don't check for it.
|
# cx_Freeze is hard to install (needs C extensions) so we don't check for it.
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import httpbin
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
|
||||||
os.pardir))
|
os.pardir))
|
||||||
from scripts import setupcommon
|
from scripts import setupcommon
|
||||||
@ -52,7 +54,15 @@ def get_build_exe_options():
|
|||||||
"""Get build_exe options with additional includes."""
|
"""Get build_exe options with additional includes."""
|
||||||
opts = freeze.get_build_exe_options(skip_html=True)
|
opts = freeze.get_build_exe_options(skip_html=True)
|
||||||
opts['includes'] += pytest.freeze_includes() # pylint: disable=no-member
|
opts['includes'] += pytest.freeze_includes() # pylint: disable=no-member
|
||||||
opts['includes'] += ['unittest.mock', 'PyQt5.QtTest', 'hypothesis', 'bs4']
|
opts['includes'] += ['unittest.mock', 'PyQt5.QtTest', 'hypothesis', 'bs4',
|
||||||
|
'httpbin', 'jinja2.ext']
|
||||||
|
|
||||||
|
httpbin_dir = os.path.dirname(httpbin.__file__)
|
||||||
|
opts['include_files'] += [
|
||||||
|
('tests/integration/data', 'integration/data'),
|
||||||
|
(os.path.join(httpbin_dir, 'templates'), 'integration/templates'),
|
||||||
|
]
|
||||||
|
|
||||||
opts['packages'].append('qutebrowser')
|
opts['packages'].append('qutebrowser')
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
@ -62,7 +72,9 @@ def main():
|
|||||||
with temp_git_commit_file():
|
with temp_git_commit_file():
|
||||||
cx.setup(
|
cx.setup(
|
||||||
executables=[cx.Executable('scripts/dev/run_frozen_tests.py',
|
executables=[cx.Executable('scripts/dev/run_frozen_tests.py',
|
||||||
targetName='run-frozen-tests')],
|
targetName='run-frozen-tests'),
|
||||||
|
cx.Executable('tests/integration/webserver.py',
|
||||||
|
targetName='webserver')],
|
||||||
options={'build_exe': get_build_exe_options()},
|
options={'build_exe': get_build_exe_options()},
|
||||||
**setupcommon.setupdata
|
**setupcommon.setupdata
|
||||||
)
|
)
|
||||||
|
@ -125,8 +125,15 @@ class HTTPBin(QObject):
|
|||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Start the webserver."""
|
"""Start the webserver."""
|
||||||
filename = os.path.join(os.path.dirname(__file__), 'webserver.py')
|
if hasattr(sys, 'frozen'):
|
||||||
self.proc.start(sys.executable, [filename, str(self.port)])
|
executable = os.path.join(os.path.dirname(sys.executable),
|
||||||
|
'webserver')
|
||||||
|
args = []
|
||||||
|
else:
|
||||||
|
executable = sys.executable
|
||||||
|
args = [os.path.join(os.path.dirname(__file__), 'webserver.py')]
|
||||||
|
|
||||||
|
self.proc.start(executable, args + [str(self.port)])
|
||||||
ok = self.proc.waitForStarted()
|
ok = self.proc.waitForStarted()
|
||||||
assert ok
|
assert ok
|
||||||
self.proc.readyRead.connect(self.read_log)
|
self.proc.readyRead.connect(self.read_log)
|
||||||
|
@ -31,9 +31,22 @@ import flask
|
|||||||
|
|
||||||
@app.route('/data/<path:path>')
|
@app.route('/data/<path:path>')
|
||||||
def send_data(path):
|
def send_data(path):
|
||||||
|
if hasattr(sys, 'frozen'):
|
||||||
|
basedir = os.path.realpath(os.path.dirname(sys.executable))
|
||||||
|
data_dir = os.path.join(basedir, 'integration', 'data')
|
||||||
|
else:
|
||||||
basedir = os.path.realpath(os.path.dirname(__file__))
|
basedir = os.path.realpath(os.path.dirname(__file__))
|
||||||
|
data_dir = os.path.join(basedir, 'data')
|
||||||
print(basedir)
|
print(basedir)
|
||||||
return flask.send_from_directory(os.path.join(basedir, 'data'), path)
|
return flask.send_from_directory(data_dir, path)
|
||||||
|
|
||||||
|
|
||||||
app.run(port=int(sys.argv[1]), debug=True, use_reloader=False)
|
def main():
|
||||||
|
if hasattr(sys, 'frozen'):
|
||||||
|
basedir = os.path.realpath(os.path.dirname(sys.executable))
|
||||||
|
app.template_folder = os.path.join(basedir, 'integration', 'templates')
|
||||||
|
app.run(port=int(sys.argv[1]), debug=True, use_reloader=False)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
2
tox.ini
2
tox.ini
@ -56,7 +56,7 @@ basepython = python3
|
|||||||
passenv = {[testenv]passenv}
|
passenv = {[testenv]passenv}
|
||||||
skip_install = true
|
skip_install = true
|
||||||
deps =
|
deps =
|
||||||
{[testenv]deps}
|
{[testenv:py34-integration]deps}
|
||||||
cx_Freeze==4.3.4
|
cx_Freeze==4.3.4
|
||||||
commands =
|
commands =
|
||||||
{envpython} scripts/link_pyqt.py --tox {envdir}
|
{envpython} scripts/link_pyqt.py --tox {envdir}
|
||||||
|
Loading…
Reference in New Issue
Block a user