general: move most core tests inside my.core.tests package
- distributes tests alongside the package, might be convenient for package users - removes some weird indirection (e.g. dummy test files improting tests from modules) - makes the command line for tests cleaner (e.g. no need to remember to manually add files to tox.ini) - tests automatically covered by mypy (so makes mypy runs cleaner and ultimately better coverage) The (vague) convention is - tests/somemodule.py -- testing my.core.somemodule, contains tests directly re - tests/test_something.py -- testing a specific feature, e.g. test_get_files.py tests get_files methon only
This commit is contained in:
parent
04d976f937
commit
9594caa1cd
18 changed files with 77 additions and 102 deletions
29
my/core/tests/test_tmp_config.py
Normal file
29
my/core/tests/test_tmp_config.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from ..cfg import tmp_config
|
||||
|
||||
|
||||
def _init_default_config() -> None:
|
||||
import my.config
|
||||
|
||||
class default_config:
|
||||
count = 5
|
||||
|
||||
my.config.simple = default_config # type: ignore[assignment,misc]
|
||||
|
||||
|
||||
def test_tmp_config() -> None:
|
||||
## ugh. ideally this would be on the top level (would be a better test)
|
||||
## but pytest imports eveything first, executes hooks, and some reset_modules() fictures mess stuff up
|
||||
## later would be nice to be a bit more careful about them
|
||||
_init_default_config()
|
||||
from my.simple import items
|
||||
|
||||
assert len(list(items())) == 5
|
||||
|
||||
class config:
|
||||
class simple:
|
||||
count = 3
|
||||
|
||||
with tmp_config(modules='my.simple', config=config):
|
||||
assert len(list(items())) == 3
|
||||
|
||||
assert len(list(items())) == 5
|
Loading…
Add table
Add a link
Reference in a new issue