Another approach would be to use pytest markers to group your tests in a more structured way, especially if you plan to reuse test sets frequently.
You can mark your tests in the code like this:
import pytest
@pytest.mark.test_001
def test_001():
assert True
@pytest.mark.test_some_other_test
def test_some_other_test():
assert True
Next, create a file called markers.txt containing the list of markers you want to run:
test_001
test_some_other_test
Then, you can use a loop to run pytest for each marker:
for marker in $(cat markers.txt); do
pytest -m $marker
done
This way, you leverage pytest’s marker feature to pytest run specific test cases associated with each marker, giving you even more control and flexibility.