Skip to content

Commit 820ea6d

Browse files
authored
Update Freezing pytest description in simple.rst
I have trouble using third party plugins in my frozen program and discovered that other people have experienced it as well: https://mail.python.org/pipermail//pytest-dev/2015-June/003015.html The problem is that the mechanism for plugin discovery used by pytest (setupttools entry points) doesn't work with frozen executables so pytest can't find any plugins. The solution seems to be to import the third party plugins explicitly as shown here: https://mail.python.org/pipermail//pytest-dev/2015-June/003018.html This is not mentioned anywhere in the documentaion.
1 parent cf9b31b commit 820ea6d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doc/en/example/simple.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,15 +826,20 @@ Instead of freezing the pytest runner as a separate executable, you can make
826826
your frozen program work as the pytest runner by some clever
827827
argument handling during program startup. This allows you to
828828
have a single executable, which is usually more convenient.
829+
Please note that the mechanism for plugin discovery used by pytest
830+
(setupttools entry points) doesn't work with frozen executables so pytest
831+
can't find any third party plugins automatically. To include third party plugins
832+
like ``pytest-timeout`` they must be imported explicitly and passed on to pytest.main.
829833

830834
.. code-block:: python
831835
832836
# contents of app_main.py
833837
import sys
838+
import pytest_timeout # Third party plugin
834839
835840
if len(sys.argv) > 1 and sys.argv[1] == '--pytest':
836841
import pytest
837-
sys.exit(pytest.main(sys.argv[2:]))
842+
sys.exit(pytest.main(sys.argv[2:], plugins=[pytest_timeout]))
838843
else:
839844
# normal application execution: at this point argv can be parsed
840845
# by your argument-parsing library of choice as usual
@@ -845,3 +850,4 @@ This allows you to execute tests using the frozen
845850
application with standard ``pytest`` command-line options::
846851

847852
./app_main --pytest --verbose --tb=long --junitxml=results.xml test-suite/
853+

0 commit comments

Comments
 (0)