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

Eliminate warnings in tests #214

Merged
merged 5 commits into from
Mar 1, 2021
Merged

Eliminate warnings in tests #214

merged 5 commits into from
Mar 1, 2021

Conversation

macfreek
Copy link
Contributor

@macfreek macfreek commented Feb 25, 2021

Fix all warnings and errors in the test suite. All test can now be run as either python setup.py test or pytest. Even in most verbose pytest -r A -W d.

See #213 or individual commits for details.

If the `args` parameter is not set when calling TestCase.assertParseArgsRaises, `args` is set to `sys.argv`, which makes the test output dependent on how the test suit was called. For example, it would succeed for `pytest`, but fail with `pytest -v` or `pytest -k testConfigOrEnvValueErrors`.

Change signature of assertParseArgsRaises() to ensure args is always present, and all other parameters are named.
pytest tries to collect tests from TestHelpFormattingMetaclass, and test_main, and raises a warning when it finds it's not a test class nor test function. Renaming TestHelpFormattingMetaclass and test_main prevents pytest from trying.
ArgumentParser._open_config_files() opens multiple configuration files, and returns the file streams. If one of the file open() operations fail, and exception is raised. E.g. file not found.
However, this never returns nor closes the previously opened files, leaving dangling file pointers. This commit fixes the issue by closing previously opened config files when an exception occurs.
The file handle `cfg_f` in `testConstructor_WriteOutConfigFileArgs`, `testConstructor_WriteOutConfigFileArgs2` and `testConstructor_WriteOutConfigFileArgsLong` was never closed. Both unittest and `pytest -Wd` reported this as a warning.
Capture output of print_values, instead of sending the irrelevant output to stderr. Also add a superficial verification that it contains relevant output.
@macfreek
Copy link
Contributor Author

This PR closes #213, which contains further details.

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.

None yet

2 participants