Refactor tests to use example tree sequences and parametrize #1804
Labels
Infrastructure and tools
Development infrastructure and tools
Python API
Issue is about the Python API
refactoring
Issue is about refactoring existing code
Milestone
We currently have a mishmash of different ways of running tests on a range of different topologies. I think a good pattern will be to use pytest.mark.parametrize with a selection of tree sequences that we create once. The
get_example_tree_sequences
list in tests/test_highlevel.py is a good place to start for this (and currently used in existing PRs like #1704).We don't have to do it all at once, but it would be good to refactor a few of the places we use different topologies and set the standard pattern for how we'd to see things done in the future. To close this PR, we should:
get_example_tree_sequences()
code from tests/test_highlevel.py into it's own module (maybeexamples.py
?) and set it up so that the list of examples gets built the first time its called, and then cached afterwards.I think pytest fixtures are an anti-pattern because you're defining a global variable that the reader is supposed to understand the meaning of, and know where to find the definition. This approach is much more transparent.
So, code like this should be canonical in test files going forward:
The text was updated successfully, but these errors were encountered: