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

tests: Use pytest instead of custom test framework #3444

Merged
merged 1 commit into from
Mar 9, 2023

Conversation

bloussou
Copy link
Contributor

@bloussou bloussou commented Mar 8, 2023

This PR is :

  • adding linters on python /tests files
  • setting up pytest to simplify tests
  • fixing setup_dummy_db script to be able to rerun tests after a fail
  • fixing RollingStock.import_railjson(force=True) : https://github.com/DGEXSolutions/osrd/pull/3444/files#diff-db79c0d0d826da64bb56e867ba7cca1f5adb239fb926d4e3792c43b0dc14b7f2R108 (causing an issue when tests were launched two times without deleting manually added rolling stocks)
  • tests files have been renamed to be detected by pytest as test files, example : get_infra.py -> test_infra.py
  • ⚠️ test logic has not been changed ! ⚠️ (this move shows that there are a lot of tests without asserts, they are just checking that API is returning a 200)

To be done later:

  • create a fixture per infra and scenario to have "atomic" tests (a test is with a specific db config and should clean its changes after it has been ran).
  • Adding assertions to improve testing
  • writing more tests 🎉

close #3424
close #3425

@bloussou bloussou force-pushed the brieuc/PytestForTests branch 3 times, most recently from c7b268f to 8950a45 Compare March 8, 2023 16:38
@bloussou bloussou marked this pull request as ready for review March 8, 2023 16:48
@bloussou bloussou requested review from eckter, a team, flomonster and multun as code owners March 8, 2023 16:48
@bloussou
Copy link
Contributor Author

bloussou commented Mar 8, 2023

flomonster
flomonster previously approved these changes Mar 8, 2023
Copy link
Contributor

@flomonster flomonster left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!

Copy link
Contributor

@eckter eckter left a comment

Choose a reason for hiding this comment

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

This is very nice, we should have done this a long time ago

tests/tests/utils/simulation.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/tests/test_regressions.py Outdated Show resolved Hide resolved
tests/tests/test_regressions.py Outdated Show resolved Hide resolved
tests/tests/test_regressions.py Outdated Show resolved Hide resolved
tests/tests/test_regressions.py Outdated Show resolved Hide resolved
@bloussou bloussou merged commit 556db85 into dev Mar 9, 2023
@bloussou bloussou deleted the brieuc/PytestForTests branch March 9, 2023 10:20
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.

Make python integration tests code under /tests follow linter rules Use pytest for integration tests
3 participants