test.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from __future__ import annotations
  2. from typing import NoReturn
  3. from setuptools import Command
  4. from setuptools.warnings import SetuptoolsDeprecationWarning
  5. # Would restrict to Literal["test"], but mypy doesn't support it: https://github.com/python/mypy/issues/8203
  6. def __getattr__(name: str) -> type[_test]:
  7. if name == 'test':
  8. SetuptoolsDeprecationWarning.emit(
  9. "The test command is disabled and references to it are deprecated.",
  10. "Please remove any references to `setuptools.command.test` in all "
  11. "supported versions of the affected package.",
  12. due_date=(2024, 11, 15),
  13. stacklevel=2,
  14. )
  15. return _test
  16. raise AttributeError(name)
  17. class _test(Command):
  18. """
  19. Stub to warn when test command is referenced or used.
  20. """
  21. description = "stub for old test command (do not use)"
  22. user_options = [
  23. ('test-module=', 'm', "Run 'test_suite' in specified module"),
  24. (
  25. 'test-suite=',
  26. 's',
  27. "Run single test, case or suite (e.g. 'module.test_suite')",
  28. ),
  29. ('test-runner=', 'r', "Test runner to use"),
  30. ]
  31. def initialize_options(self) -> None:
  32. pass
  33. def finalize_options(self) -> None:
  34. pass
  35. def run(self) -> NoReturn:
  36. raise RuntimeError("Support for the test command was removed in Setuptools 72")