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:
Dima Gerasimov 2023-05-24 23:39:21 +01:00 committed by karlicoss
parent 04d976f937
commit 9594caa1cd
18 changed files with 77 additions and 102 deletions

29
tox.ini
View file

@ -19,12 +19,26 @@ passenv =
[testenv:tests-core]
commands =
pip install -e .[testing]
# seems that denylist tests rely on it? ideally we should get rid of this in tests-core
pip install orjson
{envpython} -m pytest \
tests/core.py \
tests/sqlite.py \
tests/get_files.py \
tests/test_tmp_config.py \
{posargs}
# importlib is the new suggested import-mode
# without it test package names end up as core.tests.* instead of my.core.tests.*
--import-mode=importlib \
--pyargs my.core \
# ignore orgmode because it imports orgparse
# tbh not sure if it even belongs to core, maybe move somewhere else..
# same with pandas?
--ignore my/core/orgmode.py \
# causes error during test collection on 3.8
# dataset is deprecated anyway so whatever
--ignore my/core/dataset.py \
# this test uses orjson which is an optional dependency
# it would be covered by tests-all
-k 'not test_nt_serialize' \
{posargs}
# todo maybe also have core tests and misc tests? since ideally want them without dependencies
@ -94,11 +108,6 @@ commands =
{posargs}
cat .coverage.mypy-core/index.txt
# todo hmm might be better to move modules test in a separate subpackage?
{envpython} -m mypy --install-types --non-interactive \
tests \
--exclude 'tests/(bluemaestro|emfit|takeout|pdfs|jawbone).py'
# specific modules that are known to be mypy compliant (to avoid false negatives)
# todo maybe split into separate jobs? need to add comment how to run