Skip to content

Conversation

AluisioASG
Copy link
Contributor

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. 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 if it exists.

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/
@bobbui
Copy link
Owner

bobbui commented Apr 24, 2021

@AluisioASG looks good. Thanks for your contribution

@bobbui bobbui merged commit a34db24 into bobbui:master Apr 24, 2021
@AluisioASG AluisioASG deleted the fix-tests-under-nixos branch April 25, 2021 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants