@@ -699,40 +699,29 @@ and run it::
699699You'll see that the fixture finalizers could use the precise reporting
700700information.
701701
702- Integrating pytest runner and cx_freeze
703- -----------------------------------------------------------
702+ Freezing pytest
703+ ---------------
704704
705705If you freeze your application using a tool like
706- `cx_freeze <https://cx-freeze.readthedocs.io >`_ in order to distribute it
707- to your end-users, it is a good idea to also package your test runner and run
708- your tests using the frozen application.
709-
710- This way packaging errors such as dependencies not being
711- included into the executable can be detected early while also allowing you to
712- send test files to users so they can run them in their machines, which can be
713- invaluable to obtain more information about a hard to reproduce bug.
714-
715- Unfortunately ``cx_freeze `` can't discover them
716- automatically because of ``pytest ``'s use of dynamic module loading, so you
717- must declare them explicitly by using ``pytest.freeze_includes() ``::
718-
719- # contents of setup.py
720- from cx_Freeze import setup, Executable
721- import pytest
722-
723- setup(
724- name="app_main",
725- executables=[Executable("app_main.py")],
726- options={"build_exe":
727- {
728- 'includes': pytest.freeze_includes()}
729- },
730- # ... other options
731- )
732-
733- If you don't want to ship a different executable just in order to run your tests,
734- you can make your program check for a certain flag and pass control
735- over to ``pytest `` instead. For example::
706+ `PyInstaller <https://pyinstaller.readthedocs.io >`_
707+ in order to distribute it to your end-users, it is a good idea to also package
708+ your test runner and run your tests using the frozen application. This way packaging
709+ errors such as dependencies not being included into the executable can be detected early
710+ while also allowing you to send test files to users so they can run them in their
711+ machines, which can be useful to obtain more information about a hard to reproduce bug.
712+
713+ Fortunately recent ``PyInstaller `` releases already have a custom hook
714+ for pytest, but if you are using another tool to freeze executables
715+ such as ``cx_freeze `` or ``py2exe ``, you can use ``pytest.freeze_includes() ``
716+ to obtain the full list of internal pytest modules. How to configure the tools
717+ to find the internal modules varies from tool to tool, however.
718+
719+ Instead of freezing the pytest runner as a separate executable, you can make
720+ your frozen program work as the pytest runner by some clever
721+ argument handling during program startup. This allows you to
722+ have a single executable, which is usually more convenient.
723+
724+ .. code-block :: python
736725
737726 # contents of app_main.py
738727 import sys
@@ -745,7 +734,7 @@ over to ``pytest`` instead. For example::
745734 # by your argument-parsing library of choice as usual
746735 ...
747736
748- This makes it convenient to execute your tests from within your frozen
749- application, using standard ``py.test `` command-line options::
737+ This allows you to execute tests using the frozen
738+ application with standard ``py.test `` command-line options::
750739
751740 ./app_main --pytest --verbose --tb=long --junitxml=results.xml test-suite/
0 commit comments