Skip to content

Commit

Permalink
Merge pull request #353 from jakelishman/fix-disutils-removal
Browse files Browse the repository at this point in the history
Reduce use of deprecated `distutils` module
  • Loading branch information
jelmer authored Sep 22, 2023
2 parents f898353 + 18e1a71 commit a0a9a53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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

0 comments on commit a0a9a53

Please sign in to comment.