calliope-project / euro-calliope

A workflow to build models of the European electricity system for Calliope.
https://euro-calliope.readthedocs.io
MIT License
31 stars 18 forks source link

Test files in different subdirectories can't have the same name #413

Open brynpickering opened 1 month ago

brynpickering commented 1 month ago

What happened?

The change to the test directory introduced in #403 creates an issue when trying to match test filenames with model output filenames. E.g., tests/models/supply/test_heat.py and tests/models/demand/test_heat.py are not allowed simultaneously. One fix would be to flatten the structure and have tests/models/test_supply_heat.py and tests/models/test_demand_heat.py. The other is to repeat the parent directory name in the filename (tests/models/supply/test_heat_supply.py).

Version

1.2.0.dev

Relevant log output

import file mismatch:
imported module 'test_heat' has this __file__ attribute:
  /Users/brynpickering/Repos/euro-calliope/tests/model/timeseries/demand/test_heat.py
which is not the same as the test file we want to collect:
  /Users/brynpickering/Repos/euro-calliope/tests/model/timeseries/supply/test_heat.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
timtroendle commented 1 month ago

I see. This is a restriction by pytest. To be fair, the case that you ran into in #408 is a bit of a special case. So maybe we don't necessarily need to change anything for most cases and handle the special cases the way you've handled them over there (the second of your two options above)?