Skip to content

[test] Add shared pytest fixtures via conftest.py#172

Open
adity1raut wants to merge 2 commits into52North:mainfrom
adity1raut:tests/add-pytest-conftest-fixtures
Open

[test] Add shared pytest fixtures via conftest.py#172
adity1raut wants to merge 2 commits into52North:mainfrom
adity1raut:tests/add-pytest-conftest-fixtures

Conversation

@adity1raut
Copy link
Copy Markdown

@adity1raut adity1raut commented Mar 12, 2026

Related Issue / Discussion:

Please delete the option which is not relevant.

Fixes Issue #XX
Relates to discussion [Improve Test Framework – GSoC 2025 Code Challenge]

Changes:

  • New tests/conftest.py – shared pytest fixtures for the WRT test suite

Further Details:

Summary:

Before: Every test file independently called basic_test_func.create_dummy_Direct_Power_Ship(),
basic_test_func.create_dummy_IsoFuel_object(), and repeated path-building
boilerplate (os.path.dirname(__file__) + joins) to set up the same objects.
This made tests harder to read and changes to test setup require edits in
multiple files.

After: A single tests/conftest.py provides session- and function-scoped
fixtures that any test can request by name. Session-scoped fixtures
(simpleship, manualship, isofuel_algorithm, isobased_algorithm,
wrt_config, ship_config) are constructed once per test run, reducing I/O
overhead. Function-scoped fixtures (base_ship_config_dict,
simpleship_from_dict) are recreated per test to prevent state leakage.

Fixtures added:

Fixture Scope Purpose
test_data_dir session Absolute path to tests/data/
tests_config_path session Path to config.tests.json
wrt_config session Config loaded from config.tests.json
ship_config session ShipConfig loaded from config.tests.json
simpleship session DirectPowerBoat with auto-calculated geometry
manualship session DirectPowerBoat with manual geometry
base_ship_config_dict function Minimal valid ship config as dict
simpleship_from_dict function DirectPowerBoat built from dict
isofuel_algorithm session IsoFuel routing algorithm object
isobased_algorithm session IsoBased routing algorithm object

Dependencies:

No new dependencies. conftest.py uses only packages already listed in
requirements.test.txt (pytest) and the existing tests/basic_test_func.py
helper module.

Changes:

Please list the central functionalities that have been changed:

  • New class / file / …
  • Modified class / file / …

Further Details:

Summary:

Please mention the relevant motivation and context of your changes and shortly describe the behaviour before and after your modifications.

Dependencies:

Please list new dependencies that are required for this modification.

PR Checklist:

In the context of this PR, I:

Please consider that PRs which do not meet the requirements specified in the checklist will not be evaluated. Also, PRs with no activities will be closed after a reasonable amount of time.

tarone-saloni and others added 2 commits March 12, 2026 16:07
Signed-off-by: Saloni Tarone <taronesaloni@gmail.com>
Signed-off-by: Aditya Raut <araut7798@gmail.com>
@kdemmich
Copy link
Copy Markdown
Collaborator

Hi @adity1raut, thank you for your PR. We appreciate the time and effort that was put into it. Please be aware that we require to follow 52 North's CLA guidelines for all PRs and, in particular, fill the 52°North Contributor License Agreement. As long as this has not been filled, I can not assign you to any issues or merge any PRs. Please don't hesitate to contact me in case of related questions.

@kdemmich kdemmich added the question Further information is requested label Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants