Separate out tests that need network access
Is the progress of being packaged for a Linux Distro NixOS https://github.com/NixOS/nixpkgs/pull/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.
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_*?
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
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?
Done (at least for GH Actions!) as of https://github.com/dlenski/python-vipaccess/commit/c490e6b772c5ce02d70ba70d1a9f2b56399ebaa0#diff-33c13e0b177bacd2f02e29bcb8aea5b49e7ce34901fd8f41fefb65defba1bd33