Skip to content

Commit 6fdb64d

Browse files
committed
tests: fix imports and test collection under some environments
While packaging json-logging for NixOS, I've come across two issues with tests. Since neither are specific to NixOS (though they may be an artifact of how the build environment is set up), I felt it'd be better to try to stream the fixes up. - While testing, the import test for Quart finds not the 'quart' package, but tests/smoketests/quart. It's been a while since I worked on this, but it seems to happen because pytest prepends the test module directory to sys.path by default [1]. To make it work with a default pytest invocation, we can simply try to import something only the real quart package provides. - If no smoketest backends are specified, it will try to find tests in a __pycache__ directory [2] if it exists. [1]: https://docs.pytest.org/en/stable/pythonpath.html [2]: https://www.python.org/dev/peps/pep-3147/
1 parent dc80372 commit 6fdb64d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

json_logging/framework/quart/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def is_quart_present():
1313
# noinspection PyPep8,PyBroadException
1414
try:
15-
import quart
15+
from quart import Quart
1616
return True
1717
except:
1818
return False

tests/smoketests/test_run_smoketest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def collect_backends():
2626
yield preset_backend
2727
else:
2828
for folder in Path(__file__).parent.iterdir():
29-
if folder.is_dir():
29+
if folder.is_dir() and folder.name != '__pycache__':
3030
yield str(folder.name)
3131

3232

0 commit comments

Comments
 (0)