Skip to content

Commit

Permalink
tox.ini - remove custom list of depends for testing: just use extras …
Browse files Browse the repository at this point in the history
…test

Most recent debate on tox.ini vs extra_depends is at
con/solidation#43 (comment)

Although I appreciate the convenience of "tox" as an entry point for testing, I
increasingly find no support for it to be "the" location for testing depends
listing. Moreover I keep running into cases of needing to fish out test
dependencies somewhere else (tox.ini, nox etc) which then can differ across
projects, and also require me to adopt some avoidable runtime etc overhead from
running those extra test shims whenever pytest is just good enough.

My arguments for generally adopting an approach of specifying test
dependencies in setup.{cfg,py} or other "generic" locations as optional are:

- pytest, and its extentions are used (imported) inside the tests.  I, in 99%
  of cases, do consider "tests" to be the part of the source code.  I would not
  consider them part of the source code whenever there is an outside test
  battery which is developed/maintained independently of the source code.

  As such, I think that dependencies for tests, as part of the source code,
  should be listed alongside with dependencies for the build/installation/run
  time dependencies.  Some distributions even do "import test" across entire
  source code distribution and thus tend to decide or to request exclusion from
  source distributions (IMHO the wrong step in most of the cases).
  Ref: dandi/dandi-schema#249

- It is unfortunate that there is no "standard" convention on how/where to
  specify such test requirements, so I think it is ok to adopt [test] as
  the general convention among our projects.

- tox.ini looses NOTHING from using "extras".

- tox.ini is the correct location to describe environments and dependncies
  for external to source code tools/modules, i.e those not imported explicitly
  anywhere in the source code.

- with description of test dependencies alongside with the main dependencies
  would benefit downstream distribution (debian, conda, gentoo, etc)
  packagers since they do not need to fish around for what other dependencies
  to install/recommend/suggest for the package.

- I do appreciate the fact that test dependencies alone are not sufficient to
  run the tests, but invocation of the pytest is standardized enough to just
  invoke it against the source code. (given dependencies are installed)

  That is e.g. how dh-python helper in Debian operates -- if pytest dependency
  announced, just run pytest automagically.
  • Loading branch information
yarikoptic committed Aug 23, 2024
1 parent 6fa61f7 commit 1f1676a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ install_requires =
benchmarks =
asv[virtualenv] ~= 0.6.0, < 0.6.2
test =
pytest
pytest-cov
pytest-mock
pytest-rerunfailures
Expand Down
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ minversion = 3.3.0
[testenv]
deps =
dev: joblib @ git+https://github.com/joblib/joblib.git
pytest
pytest-cov
pytest-mock
pytest-rerunfailures
extras =
test
commands =
pytest --pyargs {posargs} fscacher

Expand Down

0 comments on commit 1f1676a

Please sign in to comment.