Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce use of deprecated distutils module #353

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ classifier =
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Software Development :: Testing

[options]
install_requires =
# Purely to support the deprecated `TestCommand` until 3.0.
setuptools; python_version>='3.12'

[extras]
test =
testscenarios
Expand Down
12 changes: 8 additions & 4 deletions testtools/distutilscmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import sys
import warnings

from distutils.core import Command
from distutils.errors import DistutilsOptionError
try:
from setuptools import Command
from setuptools.errors import OptionError
except ModuleNotFoundError:
from distutils.core import Command
from distutils.errors import DistutilsOptionError as OptionError

from testtools.run import TestProgram, TestToolsTestRunner

Expand Down Expand Up @@ -47,12 +51,12 @@ def initialize_options(self):
def finalize_options(self):
if self.test_suite is None:
if self.test_module is None:
raise DistutilsOptionError(
raise OptionError(
"You must specify a module or a suite to run tests from")
else:
self.test_suite = self.test_module+".test_suite"
elif self.test_module:
raise DistutilsOptionError(
raise OptionError(
"You may specify a module or a suite, but not both")
self.test_args = [self.test_suite]
if self.verbose:
Expand Down