Skip to content

tests: fix, cleanup and restructure test code #2569

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

Merged
merged 9 commits into from
Dec 27, 2024
Merged

tests: fix, cleanup and restructure test code #2569

merged 9 commits into from
Dec 27, 2024

Conversation

buchdag
Copy link
Member

@buchdag buchdag commented Dec 24, 2024

This PR fixe various minor or code style issues in the test code base:

  • do not remove all containers on host during test (I can't believe we did that, that was a very pleasant surprise ...)
  • report.longrepr is now always a ReprExceptionInfo, see TestReport.longrepr is a string when pytest.fail(..., pytrace=False) is used pytest-dev/pytest#1316 and its fix
  • report.longrepr.addsection() second parameter should be a str, but container.logs() returns bytes
  • add packaging and urllib3 as explicit dependencies
  • log.warn (deprecated) -> log.warning
  • type hints have been added to conftest.py where relevant
  • remove unused imports from test files

The test files structure has also been changed so that we no longer have test files at the root of test and others in their own directory (all test files are in their own subdirectory now), and the name of the files themselves has been somewhat standardized.

@SchoNie if you happen to have the time (and since you're the only one regularly contributing test code), a review would be nice 👍

- remove unused imports in test cases
- fix code smells and code style in conftest.py
@buchdag buchdag self-assigned this Dec 24, 2024
@buchdag buchdag added the type/test PR that add missing tests or correct existing tests label Dec 24, 2024
@buchdag buchdag changed the title tests: cleanup test code tests: fix, cleanup and restructure test code Dec 24, 2024
@buchdag buchdag marked this pull request as ready for review December 24, 2024 15:37
Copy link
Contributor

@SchoNie SchoNie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, lots of files so respect going trough!
Hope that remove_all_containers did not struck your machine. Good catch.
Just some minor styling comments, maybe you did that on purpose, then just discard my suggestions.

There is a gitignore file which seems to have no purpose.

WEB_PORTS and VIRTUAL_HOST sometimes have quotations and other not. Maybe also a good moment to lint that?

@buchdag
Copy link
Member Author

buchdag commented Dec 27, 2024

@SchoNie thanks for the feedback 🙏

Regarding the blank line between standard library and third party imports, that's what the PyCharm linter does by default, I think it's applying the PEP8 style guide:

Imports should be grouped in the following order:

  1. Standard library imports.
  2. Related third party imports.
  3. Local application/library specific imports.

You should put a blank line between each group of imports.

There is a gitignore file which seems to have no purpose.

I've removed it.

WEB_PORTS and VIRTUAL_HOST sometimes have quotations and other not. Maybe also a good moment to lint that?

I've cleaned WEB_PORTS, will do VIRTUAL_HOST later.

Maybe also use pathlib here instead of os (test/test_fallback/test_fallback.py)

That's planned in the next PR 👍

@buchdag buchdag requested a review from SchoNie December 27, 2024 15:21
Copy link
Contributor

@SchoNie SchoNie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just 1 missed WEB_PORTS test_debug-endpoint/test_global.yml Line 51

Regarding the blank line between standard library and third party imports, that's what the PyCharm linter does by default, I think it's applying the PEP8 style guide:

Imports should be grouped in the following order:

  1. Standard library imports.
  2. Related third party imports.
  3. Local application/library specific imports.

You should put a blank line between each group of imports.

Nice, didn't know that, learning everyday! 🧑‍🎓

@buchdag buchdag merged commit 4ccbc3e into main Dec 27, 2024
4 checks passed
@buchdag buchdag deleted the test/cleanup branch December 27, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/test PR that add missing tests or correct existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants