high-yak-85899
07/26/2022, 8:45 PMpyudev
. Some details in the thread, but TLDR is there's different behavior between using this library in a test and source code.import pyudev
if __name__ == '__main__':
print(pyudev.__version__)
A simple library like this works totally fine when I ./pants run
it.import unittest
import pyudev
class SomeTest(unittest.TestCase):
def test_things(self):
print(pyudev.__version__)
A simple unit test like this fails with the following traceback
(mono-venv) ~/devel/monorepo (test-out-pyudev)$ ./pants test astranis-python/astranis/instruments/pyudev/library_test.py
14:43:14.87 [ERROR] Completed: Run Pytest - astranis-python/astranis/instruments/pyudev/library_test.py:tests failed (exit code 2).
============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /tmp/process-executionhKazxr, configfile: pytest.ini
plugins: typeguard-2.12.1, timeout-2.1.0, cov-3.0.0
timeout: 60.0s
timeout method: signal
timeout func_only: False
collected 0 items / 1 error
==================================== ERRORS ====================================
_ ERROR collecting astranis-python/astranis/instruments/pyudev/library_test.py _
/home/nathanael/.cache/pants/named_caches/pex_root/venvs/s/9b3c2bd3/venv/lib/python3.8/site-packages/_pytest/python.py:599: in _importtestmodule
mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
/home/nathanael/.cache/pants/named_caches/pex_root/venvs/s/9b3c2bd3/venv/lib/python3.8/site-packages/_pytest/pathlib.py:533: in import_path
importlib.import_module(module_name)
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
???
<frozen importlib._bootstrap>:991: in _find_and_load
???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:671: in _load_unlocked
???
/home/nathanael/.cache/pants/named_caches/pex_root/venvs/s/9b3c2bd3/venv/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:171: in exec_module
exec(co, module.__dict__)
astranis-python/astranis/instruments/pyudev/library_test.py:3: in <module>
import pyudev
/home/nathanael/.cache/pants/named_caches/pex_root/venvs/s/9b3c2bd3/venv/lib/python3.8/site-packages/pyudev/__init__.py:57: in <module>
from pyudev.monitor import Monitor, MonitorObserver
E File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/s/9b3c2bd3/venv/lib/python3.8/site-packages/pyudev/monitor.py", line 137
E """
E ^
E SyntaxError: invalid escape sequence \
- generated xml file: /tmp/process-executionhKazxr/astranis-python.astranis.instruments.pyudev.library_test.py.tests.xml -
=========================== short test summary info ============================
ERROR astranis-python/astranis/instruments/pyudev/library_test.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.29s ===============================
ā astranis-python/astranis/instruments/pyudev/library_test.py:tests failed in 2.28s.
Wrote test XML to `dist/test_results`
pytest.ini
, we have warnings raised as errors, so maybe that's the case here? It doesn't seem like it, though.0.23.2
bitter-ability-32190
07/26/2022, 8:51 PMSyntaxError: invalid escape sequence \
is the important messagehigh-yak-85899
07/26/2022, 8:52 PMbitter-ability-32190
07/26/2022, 8:52 PMhigh-yak-85899
07/26/2022, 8:53 PMbitter-ability-32190
07/26/2022, 8:59 PM./pants --no-process-cleanup test ...
and use the sandbox to start poking around? That'd be really helpful.
The sandbox dir will be logged on the cmdline, and you can use ./__run.sh
to run the processhigh-yak-85899
07/26/2022, 9:03 PMbitter-ability-32190
07/26/2022, 9:03 PMhigh-yak-85899
07/26/2022, 9:06 PMpytest.ini
, things are fine. I just had expected to see the warning pop up when I ./pants run
the other example.bitter-ability-32190
07/26/2022, 9:07 PM./pants run
? I'm not sure thats something our users would expect š¤high-yak-85899
07/26/2022, 9:08 PMpytest
directly, it passed.
Edit: for clarity, with our pytest.ini
file set to raise warnings as errorsbitter-ability-32190
07/26/2022, 9:17 PMsys.stderr
"high-yak-85899
07/26/2022, 9:18 PM--no-local-cache
bitter-ability-32190
07/26/2022, 9:21 PM