Source: dh-python
Version: 5.20230130
Severity: wishlist

copy_test_files() defaults to copying "test" and "tests", allowing
further customization through pybuild.testfiles. This is great, and a
sane default that does the right thing most of the time!

In that spirit, it may make sense to also copy the test runner's
configuration by default, as that may customize the test runner in a way
that affects test execution. That could be in either direction: making
them stricter, looser, or configuring the runner in a way that it works,
specifically for the package.

For example, for pytest, this config could take the form of pytest.ini
and pyproject.toml. Enumerating config files for all may be a bit
annoying, so perhaps a sane default could just be to limit this to just
pyproject.toml. That could perhaps encourage maintainers to work with
their upstreams to migrate the config as well :)

A real-world example of this is src:python-structlog, which has in its
pyproject.toml:
  [tool.pytest.ini_options]
  addopts = ["-ra", "--strict-markers", "--strict-config"]
  testpaths = "tests"
  xfail_strict = true
  filterwarnings = ["once::Warning"]
  asyncio_mode = "auto"

asyncio_mode (for pytest-asyncio) is of particular interest, as that
defaults to "strict" and can easily make a test suite fail or succeed.
In structlog's case this is handled gracefully, and without it the
testsuite just skips the async tests, which is OK, but reduces test
coverage.

I've worked around this by "tests\npyproject.toml\n" to
pybuild.testfiles, but I figured it may make sense for such a config to
be the default.

Thanks for the consideration!

Best,
Faidon

Reply via email to