Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 52a97bf

Browse files
committed
test: Add --testfile option to setup.py test, allow running a single file.
1 parent 6b4e008 commit 52a97bf

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

setup.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ def run(self):
5151
class TestCommand(TestBaseCommand):
5252

5353
description = "Runs a quick unit test suite"
54+
user_options = TestBaseCommand.user_options + \
55+
[("testfile=", None, "Specific test file to run (e.g "
56+
"validation, storage, ...)"),]
57+
58+
def initialize_options(self):
59+
TestBaseCommand.initialize_options(self)
60+
self.testfile = None
61+
62+
def finalize_options(self):
63+
TestBaseCommand.finalize_options(self)
5464

5565
def run(self):
5666
'''
@@ -61,9 +71,15 @@ def run(self):
6171
if (not t.endswith('__init__.py') and
6272
not t.endswith("urltest.py") and
6373
not t.endswith("clitest.py")):
64-
testfiles.append('.'.join(
65-
['tests', splitext(basename(t))[0]])
66-
)
74+
75+
if self.testfile:
76+
base = os.path.basename(t)
77+
check = os.path.basename(self.testfile)
78+
if base != check and base != (check + ".py"):
79+
continue
80+
81+
testfiles.append('.'.join(['tests',
82+
splitext(basename(t))[0]]))
6783
self._testfiles = testfiles
6884
TestBaseCommand.run(self)
6985

0 commit comments

Comments
 (0)