Hi everyone,
I'm having trouble getting "pytest.main()" to run inside a frozen script
created by cx_freeze (12-line source code here:
https://gist.github.com/nicoddemus/5458ca3fc5241cedaff3); when I run the
generated executable (I'm on windows), I get this exception:
Traceback (most recent call last):
File
"X:\pytest_cx_freeze\.env27\lib\site-packages\cx_Freeze\initscripts\Console.py",
line 27, in <module>
exec(code, m.__dict__)
File "runtests.py", line 1, in <module>
import pytest, sys
File "X:\pytest_cx_freeze\.env27\lib\site-packages\pytest.py", line 14,
in <module>
from _pytest.config import main, UsageError, _preloadplugins, cmdline
File "X:\pytest_cx_freeze\.env27\lib\site-packages\_pytest\config.py",
line 398, in <module>
class MyOptionParser(py.std.argparse.ArgumentParser):
File "X:\pytest_cx_freeze\.env27\lib\site-packages\py\_apipkg.py", line
124, in __makeattr
result = importobj(modpath, attrname)
File "X:\pytest_cx_freeze\.env27\lib\site-packages\py\_apipkg.py", line
47, in importobj
module = __import__(modpath, None, None, ['__doc__'])
ImportError: No module named _std
I have tried to explicitly import "py._std" on my script, but it also fails:
File "X:\pytest_cx_freeze\.env27\lib\site-packages\_pytest\config.py",
line 398, in <module>
class MyOptionParser(py.std.argparse.ArgumentParser):
File "X:\pytest_cx_freeze\.env27\lib\site-packages\py\_std.py", line 15,
in __getattr__
raise AttributeError("py.std: could not import %s" % name)
AttributeError: py.std: could not import argparse
Looks like py's lazy import machinery can't be tracked by cx_freeze.
A google search didn't reveal anything useful so for far, unfortunately.
Any thoughts?
Long story for those interested: we package our desktop applications as
executables for both windows and linux using cx_freeze. Traditionally, we
also pack the test runner into the executable in order to run the
test suite using the packed code, with the test runner being activated by a
`--selftest` flag. This ensures everything the application needs to run is
correctly packed into the executable, and also enables us to write test
scripts and hand them over to customers to run on their site in order to
track a bug or to test something out.
Best Regards,
Bruno.
_______________________________________________
Pytest-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-dev