Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate out tests that need network access #30

Open
worldofpeace opened this issue Aug 5, 2019 · 4 comments
Open

Separate out tests that need network access #30

worldofpeace opened this issue Aug 5, 2019 · 4 comments

Comments

@worldofpeace
Copy link

worldofpeace commented Aug 5, 2019

Is the progress of being packaged for a Linux Distro NixOS NixOS/nixpkgs#65570, we had to exclude certain tests from the testsuite because they required network access.
Tests in question were:

  • test_check_token_detects_valid_hotp_token
  • test_check_token_detects_valid_totp_token
  • test_check_token_detects_invalid_token

This is because packages are prohibited from being built with network access in NixOS.
You may come to find that in many other Linux distros that it's a very common practice
to want to run tests within the source distribution.
This allows us to test that a package installed successfully with our build expressions and dependencies.
Prohibition of network access on builders is also common, in particular with Fedora
which is quite keen to packaging python libraries.

@dlenski
Copy link
Owner

dlenski commented Aug 5, 2019

Understood, and thanks for the feedback.

Keep in mind that this is a very network-centric application: it entirely depends on a proprietary web service for token provisioning to work. If that proprietary web service changes, this application will be useless for provisioning new tokens.

So I do want to keep these tests in the source distribution.

Perhaps it'd be helpful to add a naming convention for which tests require network access? E.g. test_NET_REQUIRED_*?

@worldofpeace
Copy link
Author

Perhaps it'd be helpful to add a naming convention for which tests require network access? E.g. test_NET_REQUIRED_*?

How about a separate directory? so like

tests/integration
tests/network

I don't think pytest really gives you granular control over this

@worldofpeace
Copy link
Author

And maybe also do with pytest configuration

[pytest]
testpaths = tests/integration

so when pytest in executed in the root it doesn't default run the network tests?

@dlenski
Copy link
Owner

dlenski commented Feb 12, 2024

Done (at least for GH Actions!) as of c490e6b#diff-33c13e0b177bacd2f02e29bcb8aea5b49e7ce34901fd8f41fefb65defba1bd33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants