Skip to content

Commit 74ef645

Browse files
committed
setup.py: Add 'tests --only [str]' for test filtering
1 parent 57f00f2 commit 74ef645

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ class TestCommand(Command):
2222
"Run read/write functional tests against actual bugzilla instances. "
2323
"As of now this only runs against partner-bugzilla.redhat.com, "
2424
"which requires an RH bugzilla account with cached cookies. "
25-
"This will also be very slow.")
25+
"This will also be very slow."),
26+
("only=", None,
27+
"Run only tests whose name contains the passed string"),
2628
]
2729

2830
def initialize_options(self):
2931
self.ro_functional = False
3032
self.rw_functional = False
33+
self.only = None
3134

3235
def finalize_options(self):
3336
pass
@@ -65,6 +68,15 @@ def run(self):
6568
print "installHandler hack failed"
6669

6770
tests = unittest.TestLoader().loadTestsFromNames(testfiles)
71+
if self.only:
72+
newtests = []
73+
for suite1 in tests:
74+
for suite2 in suite1:
75+
for testcase in suite2:
76+
if self.only in str(testcase):
77+
newtests.append(testcase)
78+
tests = unittest.TestSuite(newtests)
79+
6880
t = unittest.TextTestRunner(verbosity=1)
6981

7082
result = t.run(tests)

0 commit comments

Comments
 (0)