You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the test setup uses unittest, uses the EclTest class to inject information about where test-data is located and what testdata is available, and TestAreaContext to create temporary working directories. It would greatly simplify managing test data if this were to be moved to using pytest fixtures. As a bonus: this can be done on a per-test basis, and you don't need to move every file to pytest at once!
Here the TestAreaContext sets up the temporary directory to work in, @equinor_test marks this as a test that uses equinor data and createTestPath ammends the path to the test data directory. It would probably be cleaner to separate these conserns using pytest fixtures so that the finding of test data is abstracted away:
This uses the builtin tmp_path fixture to set up a temporary directory.
Fixtures can be collected into one module so that they will only have to be imported in conftest.py in order to be registered and available to all tests.
Really, test_grid_save_roundtrip should work with any grid, and we can create a fixture that reruns the test with
any number of grids:
Currently the test setup uses
unittest
, uses theEclTest
class to inject information about where test-data is located and what testdata is available, andTestAreaContext
to create temporary working directories. It would greatly simplify managing test data if this were to be moved to using pytest fixtures. As a bonus: this can be done on a per-test basis, and you don't need to move every file to pytest at once!The
GridCoarseTest
uses all of these features:https://github.com/equinor/ecl/blob/6bd69ef5c0a2455433cd67a7c622d62fab32bb74/python/tests/ecl_tests/test_grid_equinor_coarse.py#L24-L42
Here the TestAreaContext sets up the temporary directory to work in, @equinor_test marks this as a test that uses equinor data and createTestPath ammends the path to the test data directory. It would probably be cleaner to separate these conserns using pytest fixtures so that the finding of test data is abstracted away:
Lets first look at the simple case of the assert statement at the end of the
GridCoarseTest
:The
pytest.mark.uses_equinor_data
could be set up to skip the test unless a flag is given to pytest, orthe Equinor symlink is present as it is now.
As for the first part:
This uses the builtin tmp_path fixture to set up a temporary directory.
Fixtures can be collected into one module so that they will only have to be imported in
conftest.py
in order to be registered and available to all tests.Really,
test_grid_save_roundtrip
should work with any grid, and we can create a fixture that reruns the test withany number of grids:
parametrized fixtures is very useful for cleaning up tests that now loop over a generated list of grids: https://github.com/equinor/ecl/blob/6bd69ef5c0a2455433cd67a7c622d62fab32bb74/python/tests/ecl_tests/test_grid.py#L410-L414
which could be written as
where
any_small_grid
is the parametrized fixture now generated bycreateVolumeTestGridBase
.The text was updated successfully, but these errors were encountered: