From 990e7bf3b9f8505ed3e0fa29074e4c937857f451 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Jul 2014 19:16:51 -0300 Subject: [PATCH 1/7] first implementation and tox environment for cx-freeze support --HG-- branch : cx_freeze-support --- _pytest/cx_freeze_support.py | 52 ++++++++++++++++++++++++ pytest.py | 1 + testing/cx_freeze/run.py | 7 ++++ testing/cx_freeze/runtests_script.py | 10 +++++ testing/cx_freeze/runtests_setup.py | 11 +++++ testing/cx_freeze/tests/test_doctest.txt | 6 +++ testing/cx_freeze/tests/test_trivial.py | 6 +++ tox.ini | 8 ++++ 8 files changed, 101 insertions(+) create mode 100644 _pytest/cx_freeze_support.py create mode 100644 testing/cx_freeze/run.py create mode 100644 testing/cx_freeze/runtests_script.py create mode 100644 testing/cx_freeze/runtests_setup.py create mode 100644 testing/cx_freeze/tests/test_doctest.txt create mode 100644 testing/cx_freeze/tests/test_trivial.py diff --git a/_pytest/cx_freeze_support.py b/_pytest/cx_freeze_support.py new file mode 100644 index 000000000..84b2a11ee --- /dev/null +++ b/_pytest/cx_freeze_support.py @@ -0,0 +1,52 @@ + + +def includes(): + return [ + '_pytest.assertion.newinterpret', + '_pytest.assertion.oldinterpret', + '_pytest.assertion.reinterpret', + '_pytest.assertion.rewrite', + '_pytest.assertion.util', + + '_pytest._argcomplete', + '_pytest.doctest', + '_pytest.pdb', + '_pytest.unittest', + '_pytest.capture', + '_pytest.config', + '_pytest.core', + '_pytest.genscript', + '_pytest.helpconfig', + '_pytest.hookspec', + '_pytest.junitxml', + '_pytest.main', + '_pytest.mark', + '_pytest.monkeypatch', + '_pytest.nose', + '_pytest.pastebin', + '_pytest.pytester', + '_pytest.python', + '_pytest.recwarn', + '_pytest.resultlog', + '_pytest.runner', + '_pytest.skipping', + '_pytest.standalonetemplate', + '_pytest.terminal', + '_pytest.tmpdir', + + 'py._builtin', + 'py._path.local', + 'py._io.capture', + 'py._io.saferepr', + 'py._iniconfig', + 'py._io.terminalwriter', + 'py._xmlgen', + 'py._error', + 'py._std', + + # builtin files imported by pytest using py.std implicit mechanism + 'argparse', + 'shlex', + 'warnings', + 'types', + ] \ No newline at end of file diff --git a/pytest.py b/pytest.py index 6c25c6195..b84cb2a17 100644 --- a/pytest.py +++ b/pytest.py @@ -13,6 +13,7 @@ if __name__ == '__main__': # if run as a script or by 'python -m pytest' from _pytest.config import main, UsageError, _preloadplugins, cmdline from _pytest import __version__ +from _pytest import cx_freeze_support _preloadplugins() # to populate pytest.* namespace so help(pytest) works diff --git a/testing/cx_freeze/run.py b/testing/cx_freeze/run.py new file mode 100644 index 000000000..d52906df3 --- /dev/null +++ b/testing/cx_freeze/run.py @@ -0,0 +1,7 @@ +import os +import sys + +executable = os.path.join(os.getcwd(), 'build', 'runtests_script') +if sys.platform.startswith('win'): + executable += '.exe' +sys.exit(os.system('%s tests' % executable)) \ No newline at end of file diff --git a/testing/cx_freeze/runtests_script.py b/testing/cx_freeze/runtests_script.py new file mode 100644 index 000000000..d3e32ec82 --- /dev/null +++ b/testing/cx_freeze/runtests_script.py @@ -0,0 +1,10 @@ +""" +Simple script that actually executes py.test runner when passed "--pytest" as +first argument; in this case, all other arguments are forwarded to pytest's +main(). +""" + +if __name__ == '__main__': + import sys + import pytest + sys.exit(pytest.main()) \ No newline at end of file diff --git a/testing/cx_freeze/runtests_setup.py b/testing/cx_freeze/runtests_setup.py new file mode 100644 index 000000000..3d15a5a82 --- /dev/null +++ b/testing/cx_freeze/runtests_setup.py @@ -0,0 +1,11 @@ +from cx_Freeze import setup, Executable + +import pytest +setup( + name="runtests", + version="0.1", + description="exemple of how embedding py.test into an executable using cx_freeze", + executables=[Executable("runtests_script.py")], + options={"build_exe": {'includes': pytest.cx_freeze_support.includes()}}, +) + diff --git a/testing/cx_freeze/tests/test_doctest.txt b/testing/cx_freeze/tests/test_doctest.txt new file mode 100644 index 000000000..82159edb4 --- /dev/null +++ b/testing/cx_freeze/tests/test_doctest.txt @@ -0,0 +1,6 @@ + + +Testing doctest:: + + >>> 1 + 1 + 2 diff --git a/testing/cx_freeze/tests/test_trivial.py b/testing/cx_freeze/tests/test_trivial.py new file mode 100644 index 000000000..d8a572baa --- /dev/null +++ b/testing/cx_freeze/tests/test_trivial.py @@ -0,0 +1,6 @@ + +def test_upper(): + assert 'foo'.upper() == 'FOO' + +def test_lower(): + assert 'FOO'.lower() == 'foo' \ No newline at end of file diff --git a/tox.ini b/tox.ini index 8fc46de54..d0ae9c9cc 100644 --- a/tox.ini +++ b/tox.ini @@ -123,6 +123,14 @@ commands= {envpython} {envbindir}/py.test-jython \ -rfsxX --junitxml={envlogdir}/junit-{envname}2.xml [] +[testenv:py27-cxfreeze] +deps=cx_freeze +changedir=testing/cx_freeze +basepython=python2.7 +commands= + {envpython} runtests_setup.py build --build-exe build + {envpython} run.py + [pytest] minversion=2.0 plugins=pytester From b7b96b24d8441b9febe05dea070ca9ed5a110694 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Jul 2014 21:50:00 -0300 Subject: [PATCH 2/7] Docs about cx_freeze support and minor adjustments --HG-- branch : cx_freeze-support --- _pytest/cx_freeze_support.py | 90 +++++++++++++++------------- doc/en/example/simple.txt | 31 ++++------ testing/cx_freeze/run.py | 7 --- testing/cx_freeze/runtests_script.py | 5 +- testing/cx_freeze/runtests_setup.py | 5 +- testing/cx_freeze/tox_run.py | 14 +++++ tox.ini | 4 +- 7 files changed, 81 insertions(+), 75 deletions(-) delete mode 100644 testing/cx_freeze/run.py create mode 100644 testing/cx_freeze/tox_run.py diff --git a/_pytest/cx_freeze_support.py b/_pytest/cx_freeze_support.py index 84b2a11ee..fbe438bf0 100644 --- a/_pytest/cx_freeze_support.py +++ b/_pytest/cx_freeze_support.py @@ -1,52 +1,56 @@ +""" +Package to support embedding pytest runner into executable files. +.. note:: Since we are imported into pytest namespace, we use local imports to + be as cheap as possible. +""" def includes(): - return [ - '_pytest.assertion.newinterpret', - '_pytest.assertion.oldinterpret', - '_pytest.assertion.reinterpret', - '_pytest.assertion.rewrite', - '_pytest.assertion.util', + """ + Returns a list of module names used by py.test that should be + included by cx_freeze. + """ + import py + import _pytest - '_pytest._argcomplete', - '_pytest.doctest', - '_pytest.pdb', - '_pytest.unittest', - '_pytest.capture', - '_pytest.config', - '_pytest.core', - '_pytest.genscript', - '_pytest.helpconfig', - '_pytest.hookspec', - '_pytest.junitxml', - '_pytest.main', - '_pytest.mark', - '_pytest.monkeypatch', - '_pytest.nose', - '_pytest.pastebin', - '_pytest.pytester', - '_pytest.python', - '_pytest.recwarn', - '_pytest.resultlog', - '_pytest.runner', - '_pytest.skipping', - '_pytest.standalonetemplate', - '_pytest.terminal', - '_pytest.tmpdir', + result = list(_iter_all_modules(py)) + result += list(_iter_all_modules(_pytest)) - 'py._builtin', - 'py._path.local', - 'py._io.capture', - 'py._io.saferepr', - 'py._iniconfig', - 'py._io.terminalwriter', - 'py._xmlgen', - 'py._error', - 'py._std', - - # builtin files imported by pytest using py.std implicit mechanism + # builtin files imported by pytest using py.std implicit mechanism; + # should be removed if https://bitbucket.org/hpk42/pytest/pull-request/185 + # gets merged + result += [ 'argparse', 'shlex', 'warnings', 'types', - ] \ No newline at end of file + ] + return result + + +def _iter_all_modules(package, prefix=''): + """ + Iterates over the names of all modules that can be found in the given + package, recursively. + + Example: + _iter_all_modules(_pytest) -> + ['_pytest.assertion.newinterpret', + '_pytest.capture', + '_pytest.core', + ... + ] + """ + import pkgutil + import os + + if type(package) is not str: + path, prefix = package.__path__[0], package.__name__ + '.' + else: + path = package + for _, name, is_package in pkgutil.iter_modules([path]): + if is_package: + for m in _iter_all_modules(os.path.join(path, name), prefix=name + '.'): + yield prefix + m + else: + yield prefix + name diff --git a/doc/en/example/simple.txt b/doc/en/example/simple.txt index 6b6163d58..caaf1fb56 100644 --- a/doc/en/example/simple.txt +++ b/doc/en/example/simple.txt @@ -694,33 +694,26 @@ included into the executable can be detected early while also allowing you to send test files to users so they can run them in their machines, which can be invaluable to obtain more information about a hard to reproduce bug. -Unfortunately embedding the ``pytest`` runner into a frozen executable using -``cx_freeze`` is not as straightforward as one would like, -because ``pytest`` makes heavy use of dynamic module loading which -``cx_freeze`` can't resolve by itself. - -To solve this, you have to manually include ``pytest`` and ``py`` -modules by using the ``build_exe`` option in your ``setup.py`` script, like this:: +Unfortunately ``cx_freeze`` can't discover them +automatically because of ``pytest``'s use of dynamic module loading, so you +must declare them explicitly by using ``pytest.cx_freeze_support.includes()``:: # contents of setup.py from cx_Freeze import setup, Executable + import pytest - includes = [ - '_pytest.doctest', - '_pytest.unittest', - # ... lots more - ] setup( name="runtests", - options={"build_exe": {'includes': includes}}, + options={"build_exe": + { + 'includes': pytest.cx_freeze_support.includes()} + }, # ... other options ) -(For the complete list, check out the modules under ``_pytest`` in your -site-packages). - -With that, you can make your program check for a certain flag and pass control -over to ``pytest``:: +If you don't want to ship a different executable just in order to run your tests, +you can make your program check for a certain flag and pass control +over to ``pytest`` instead. For example:: # contents of app_main.py import sys @@ -734,6 +727,6 @@ over to ``pytest``:: ... This makes it convenient to execute your tests from within your frozen -application, using standard ``py.test`` command-line:: +application, using standard ``py.test`` command-line options:: $ ./app_main --pytest --verbose --tb=long --junit-xml=results.xml test-suite/ \ No newline at end of file diff --git a/testing/cx_freeze/run.py b/testing/cx_freeze/run.py deleted file mode 100644 index d52906df3..000000000 --- a/testing/cx_freeze/run.py +++ /dev/null @@ -1,7 +0,0 @@ -import os -import sys - -executable = os.path.join(os.getcwd(), 'build', 'runtests_script') -if sys.platform.startswith('win'): - executable += '.exe' -sys.exit(os.system('%s tests' % executable)) \ No newline at end of file diff --git a/testing/cx_freeze/runtests_script.py b/testing/cx_freeze/runtests_script.py index d3e32ec82..f2b032d76 100644 --- a/testing/cx_freeze/runtests_script.py +++ b/testing/cx_freeze/runtests_script.py @@ -1,7 +1,6 @@ """ -Simple script that actually executes py.test runner when passed "--pytest" as -first argument; in this case, all other arguments are forwarded to pytest's -main(). +This is the script that is actually frozen into an executable: simply executes +py.test main(). """ if __name__ == '__main__': diff --git a/testing/cx_freeze/runtests_setup.py b/testing/cx_freeze/runtests_setup.py index 3d15a5a82..56b39205d 100644 --- a/testing/cx_freeze/runtests_setup.py +++ b/testing/cx_freeze/runtests_setup.py @@ -1,6 +1,9 @@ +""" +Sample setup.py script that generates an executable with pytest runner embedded. +""" from cx_Freeze import setup, Executable - import pytest + setup( name="runtests", version="0.1", diff --git a/testing/cx_freeze/tox_run.py b/testing/cx_freeze/tox_run.py new file mode 100644 index 000000000..95ac1b858 --- /dev/null +++ b/testing/cx_freeze/tox_run.py @@ -0,0 +1,14 @@ +""" +Called by tox.ini: uses the generated executable to run the tests in ./tests/ +directory. + +.. note:: somehow calling "build/runtests_script" directly from tox doesn't + seem to work (at least on Windows). +""" +import os +import sys + +executable = os.path.join(os.getcwd(), 'build', 'runtests_script') +if sys.platform.startswith('win'): + executable += '.exe' +sys.exit(os.system('%s tests' % executable)) \ No newline at end of file diff --git a/tox.ini b/tox.ini index d0ae9c9cc..d1214f5c2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] distshare={homedir}/.tox/distshare -envlist=flakes,py26,py27,py34,pypy,py27-pexpect,py33-pexpect,py27-nobyte,py32,py33,py27-xdist,py33-xdist,py27-trial,py33-trial,doctesting +envlist=flakes,py26,py27,py34,pypy,py27-pexpect,py33-pexpect,py27-nobyte,py32,py33,py27-xdist,py33-xdist,py27-trial,py33-trial,doctesting,py27-cxfreeze [testenv] changedir=testing @@ -129,7 +129,7 @@ changedir=testing/cx_freeze basepython=python2.7 commands= {envpython} runtests_setup.py build --build-exe build - {envpython} run.py + {envpython} tox_run.py [pytest] minversion=2.0 From 82d573e39174e531835205e1945befc9b7f6e4a6 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Jul 2014 21:57:19 -0300 Subject: [PATCH 3/7] fixed line endings for test_doctest.txt --HG-- branch : cx_freeze-support --- testing/cx_freeze/tests/test_doctest.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/testing/cx_freeze/tests/test_doctest.txt b/testing/cx_freeze/tests/test_doctest.txt index 82159edb4..e18a4b68c 100644 --- a/testing/cx_freeze/tests/test_doctest.txt +++ b/testing/cx_freeze/tests/test_doctest.txt @@ -1,6 +1,6 @@ - - -Testing doctest:: - - >>> 1 + 1 - 2 + + +Testing doctest:: + + >>> 1 + 1 + 2 From 3c649cf91d831bcc066ecc141975270fe7a46846 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Jul 2014 22:28:03 -0300 Subject: [PATCH 4/7] guarding scripts with __main__ and doc changes tox-flakes environment tries to import the modules for checking, and that may fail because of its dependencies --HG-- branch : cx_freeze-support --- doc/en/example/simple.txt | 3 ++- testing/cx_freeze/runtests_setup.py | 19 ++++++++++--------- testing/cx_freeze/tox_run.py | 13 +++++++------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/doc/en/example/simple.txt b/doc/en/example/simple.txt index caaf1fb56..e42d81eec 100644 --- a/doc/en/example/simple.txt +++ b/doc/en/example/simple.txt @@ -703,7 +703,8 @@ must declare them explicitly by using ``pytest.cx_freeze_support.includes()``:: import pytest setup( - name="runtests", + name="app_main", + executables=[Executable("app_main.py")], options={"build_exe": { 'includes': pytest.cx_freeze_support.includes()} diff --git a/testing/cx_freeze/runtests_setup.py b/testing/cx_freeze/runtests_setup.py index 56b39205d..fa2373890 100644 --- a/testing/cx_freeze/runtests_setup.py +++ b/testing/cx_freeze/runtests_setup.py @@ -1,14 +1,15 @@ """ Sample setup.py script that generates an executable with pytest runner embedded. """ -from cx_Freeze import setup, Executable -import pytest +if __name__ == '__main__': + from cx_Freeze import setup, Executable + import pytest -setup( - name="runtests", - version="0.1", - description="exemple of how embedding py.test into an executable using cx_freeze", - executables=[Executable("runtests_script.py")], - options={"build_exe": {'includes': pytest.cx_freeze_support.includes()}}, -) + setup( + name="runtests", + version="0.1", + description="exemple of how embedding py.test into an executable using cx_freeze", + executables=[Executable("runtests_script.py")], + options={"build_exe": {'includes': pytest.cx_freeze_support.includes()}}, + ) diff --git a/testing/cx_freeze/tox_run.py b/testing/cx_freeze/tox_run.py index 95ac1b858..e8df2684b 100644 --- a/testing/cx_freeze/tox_run.py +++ b/testing/cx_freeze/tox_run.py @@ -5,10 +5,11 @@ directory. .. note:: somehow calling "build/runtests_script" directly from tox doesn't seem to work (at least on Windows). """ -import os -import sys +if __name__ == '__main__': + import os + import sys -executable = os.path.join(os.getcwd(), 'build', 'runtests_script') -if sys.platform.startswith('win'): - executable += '.exe' -sys.exit(os.system('%s tests' % executable)) \ No newline at end of file + executable = os.path.join(os.getcwd(), 'build', 'runtests_script') + if sys.platform.startswith('win'): + executable += '.exe' + sys.exit(os.system('%s tests' % executable)) \ No newline at end of file From d2903507d81dbe92ca84771a78a102102a2ae690 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 11 Aug 2014 20:03:14 -0300 Subject: [PATCH 5/7] Moved freeze_includes() to genscript --HG-- branch : cx_freeze-support --- _pytest/cx_freeze_support.py | 56 ---------------------------- _pytest/genscript.py | 57 ++++++++++++++++++++++++++++- pytest.py | 1 - testing/cx_freeze/runtests_setup.py | 2 +- testing/test_genscript.py | 10 +++++ 5 files changed, 67 insertions(+), 59 deletions(-) delete mode 100644 _pytest/cx_freeze_support.py diff --git a/_pytest/cx_freeze_support.py b/_pytest/cx_freeze_support.py deleted file mode 100644 index fbe438bf0..000000000 --- a/_pytest/cx_freeze_support.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -Package to support embedding pytest runner into executable files. - -.. note:: Since we are imported into pytest namespace, we use local imports to - be as cheap as possible. -""" - -def includes(): - """ - Returns a list of module names used by py.test that should be - included by cx_freeze. - """ - import py - import _pytest - - result = list(_iter_all_modules(py)) - result += list(_iter_all_modules(_pytest)) - - # builtin files imported by pytest using py.std implicit mechanism; - # should be removed if https://bitbucket.org/hpk42/pytest/pull-request/185 - # gets merged - result += [ - 'argparse', - 'shlex', - 'warnings', - 'types', - ] - return result - - -def _iter_all_modules(package, prefix=''): - """ - Iterates over the names of all modules that can be found in the given - package, recursively. - - Example: - _iter_all_modules(_pytest) -> - ['_pytest.assertion.newinterpret', - '_pytest.capture', - '_pytest.core', - ... - ] - """ - import pkgutil - import os - - if type(package) is not str: - path, prefix = package.__path__[0], package.__name__ + '.' - else: - path = package - for _, name, is_package in pkgutil.iter_modules([path]): - if is_package: - for m in _iter_all_modules(os.path.join(path, name), prefix=name + '.'): - yield prefix + m - else: - yield prefix + name diff --git a/_pytest/genscript.py b/_pytest/genscript.py index 25e8e6a0f..f7dbba36c 100755 --- a/_pytest/genscript.py +++ b/_pytest/genscript.py @@ -1,6 +1,12 @@ """ generate a single-file self-contained version of pytest """ -import py +import os import sys +import pkgutil + +import py + +import _pytest + def find_toplevel(name): for syspath in py.std.sys.path: @@ -78,3 +84,52 @@ def pytest_cmdline_main(config): tw.line("generated pytest standalone script: %s" % genscript, bold=True) return 0 + + +def pytest_namespace(): + return {'freeze_includes': freeze_includes} + + +def freeze_includes(): + """ + Returns a list of module names used by py.test that should be + included by cx_freeze. + """ + result = list(_iter_all_modules(py)) + result += list(_iter_all_modules(_pytest)) + + # builtin files imported by pytest using py.std implicit mechanism; + # should be removed if https://bitbucket.org/hpk42/pytest/pull-request/185 + # gets merged + result += [ + 'argparse', + 'shlex', + 'warnings', + 'types', + ] + return result + + +def _iter_all_modules(package, prefix=''): + """ + Iterates over the names of all modules that can be found in the given + package, recursively. + + Example: + _iter_all_modules(_pytest) -> + ['_pytest.assertion.newinterpret', + '_pytest.capture', + '_pytest.core', + ... + ] + """ + if type(package) is not str: + path, prefix = package.__path__[0], package.__name__ + '.' + else: + path = package + for _, name, is_package in pkgutil.iter_modules([path]): + if is_package: + for m in _iter_all_modules(os.path.join(path, name), prefix=name + '.'): + yield prefix + m + else: + yield prefix + name diff --git a/pytest.py b/pytest.py index b84cb2a17..6c25c6195 100644 --- a/pytest.py +++ b/pytest.py @@ -13,7 +13,6 @@ if __name__ == '__main__': # if run as a script or by 'python -m pytest' from _pytest.config import main, UsageError, _preloadplugins, cmdline from _pytest import __version__ -from _pytest import cx_freeze_support _preloadplugins() # to populate pytest.* namespace so help(pytest) works diff --git a/testing/cx_freeze/runtests_setup.py b/testing/cx_freeze/runtests_setup.py index fa2373890..a2874a655 100644 --- a/testing/cx_freeze/runtests_setup.py +++ b/testing/cx_freeze/runtests_setup.py @@ -10,6 +10,6 @@ if __name__ == '__main__': version="0.1", description="exemple of how embedding py.test into an executable using cx_freeze", executables=[Executable("runtests_script.py")], - options={"build_exe": {'includes': pytest.cx_freeze_support.includes()}}, + options={"build_exe": {'includes': pytest.freeze_includes()}}, ) diff --git a/testing/test_genscript.py b/testing/test_genscript.py index 02bbabb6f..1c65fec14 100644 --- a/testing/test_genscript.py +++ b/testing/test_genscript.py @@ -36,3 +36,13 @@ def test_gen(testdir, anypython, standalone): result = standalone.run(anypython, testdir, p) assert result.ret != 0 + +def test_freeze_includes(): + """ + Smoke test for freeze_includes(), to ensure that it works across all + supported python versions. + """ + includes = pytest.freeze_includes() + assert len(includes) > 1 + assert '_pytest.genscript' in includes + From ccd67733fbb552a7bfb22e759848960424bc698c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 11 Aug 2014 20:20:41 -0300 Subject: [PATCH 6/7] standard lib modules no longer required in freeze_includes() and updated docs --HG-- branch : cx_freeze-support --- _pytest/genscript.py | 10 ---------- doc/en/example/simple.txt | 7 +++---- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/_pytest/genscript.py b/_pytest/genscript.py index 927a31e88..f41230b8a 100755 --- a/_pytest/genscript.py +++ b/_pytest/genscript.py @@ -99,16 +99,6 @@ def freeze_includes(): """ result = list(_iter_all_modules(py)) result += list(_iter_all_modules(_pytest)) - - # builtin files imported by pytest using py.std implicit mechanism; - # should be removed if https://bitbucket.org/hpk42/pytest/pull-request/185 - # gets merged - result += [ - 'argparse', - 'shlex', - 'warnings', - 'types', - ] return result diff --git a/doc/en/example/simple.txt b/doc/en/example/simple.txt index 1f353d2c6..380f6139f 100644 --- a/doc/en/example/simple.txt +++ b/doc/en/example/simple.txt @@ -684,7 +684,7 @@ invaluable to obtain more information about a hard to reproduce bug. Unfortunately ``cx_freeze`` can't discover them automatically because of ``pytest``'s use of dynamic module loading, so you -must declare them explicitly by using ``pytest.cx_freeze_support.includes()``:: +must declare them explicitly by using ``pytest.freeze_includes()``:: # contents of setup.py from cx_Freeze import setup, Executable @@ -695,7 +695,7 @@ must declare them explicitly by using ``pytest.cx_freeze_support.includes()``:: executables=[Executable("app_main.py")], options={"build_exe": { - 'includes': pytest.cx_freeze_support.includes()} + 'includes': pytest.freeze_includes()} }, # ... other options ) @@ -718,5 +718,4 @@ over to ``pytest`` instead. For example:: This makes it convenient to execute your tests from within your frozen application, using standard ``py.test`` command-line options:: - $ ./app_main --pytest --verbose --tb=long --junit-xml=results.xml test-suite/ /bin/sh: 1: ./app_main: not found - /bin/sh: 1: ./app_main: not found + $ ./app_main --pytest --verbose --tb=long --junit-xml=results.xml test-suite/ From fc95877622e11524e8898f7a4954d6c38280ac0d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 23 Aug 2014 10:10:32 -0300 Subject: [PATCH 7/7] Added changelog entry for freeze_includes() --HG-- branch : cx_freeze-support --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8fe13a643..04ba58e8c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ NEXT ----------- +- Added function pytest.freeze_includes(), which makes it easy to embed + pytest into executables using tools like cx_freeze. + See docs for examples and rationale. Thanks Bruno Oliveira. + - fixed issue561: adapt autouse fixture example for python3. - Fix example in monkeypatch documentation, thanks t-8ch.