Docs about cx_freeze support and minor adjustments

--HG--
branch : cx_freeze-support
This commit is contained in:
Bruno Oliveira
2014-07-30 21:50:00 -03:00
parent 990e7bf3b9
commit b7b96b24d8
7 changed files with 81 additions and 75 deletions

View File

@@ -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/