Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0ef90a6

Browse files
authored
Add outsuffix option (#238)
1 parent 531da78 commit 0ef90a6

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

‎tests/testsuite.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,27 @@ def test_xmlrunner_output_file(self, exiter, testrunner, opener):
989989
testrunner.assert_called_once_with(**kwargs)
990990
exiter.assert_called_once_with(False)
991991

992+
@mock.patch('sys.argv', ['xmlrunner', '--outsuffix', ''])
993+
@mock.patch('xmlrunner.runner.open')
994+
@mock.patch('xmlrunner.runner.XMLTestRunner')
995+
@mock.patch('sys.exit')
996+
def test_xmlrunner_outsuffix(self, exiter, testrunner, opener):
997+
xmlrunner.runner.XMLTestProgram()
998+
999+
kwargs = dict(
1000+
buffer=mock.ANY,
1001+
failfast=mock.ANY,
1002+
verbosity=mock.ANY,
1003+
warnings=mock.ANY,
1004+
outsuffix='',
1005+
)
1006+
1007+
if sys.version_info[:2] > (3, 4):
1008+
kwargs.update(tb_locals=mock.ANY)
1009+
1010+
testrunner.assert_called_once_with(**kwargs)
1011+
exiter.assert_called_once_with(False)
1012+
9921013

9931014
class ResolveFilenameTestCase(unittest.TestCase):
9941015
@mock.patch('os.path.relpath')

‎xmlrunner/runner.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class XMLTestRunner(TextTestRunner):
1515
"""
1616
A test runner class that outputs the results in JUnit like XML files.
1717
"""
18-
def __init__(self, output='.', outsuffix=None,
18+
19+
def __init__(self, output='.', outsuffix=None,
1920
elapsed_times=True, encoding=UTF8,
2021
resultclass=None,
2122
**kwargs):
@@ -138,9 +139,13 @@ def _parseKnownArgs(self, kwargs):
138139
group.add_argument(
139140
'--output-file', metavar='FILENAME',
140141
help='Filename for storing XML report')
142+
parser.add_argument(
143+
'--outsuffix', metavar='STRING',
144+
help='Output suffix (timestamp is default)')
141145
namespace, argv = parser.parse_known_args(argv)
142146
self.output = namespace.output
143147
self.output_file = namespace.output_file
148+
self.outsuffix = namespace.outsuffix
144149
kwargs['argv'] = argv
145150

146151
def _initArgParsers(self):
@@ -155,6 +160,9 @@ def _initArgParsers(self):
155160
group.add_argument(
156161
'--output-file', metavar='FILENAME', nargs=1,
157162
help='Filename for storing XML report')
163+
group.add_argument(
164+
'--outsuffix', metavar='STRING', nargs=1,
165+
help='Output suffix (timestamp is default)')
158166

159167
def runTests(self):
160168
kwargs = dict(
@@ -174,6 +182,9 @@ def runTests(self):
174182
elif self.output is not None:
175183
kwargs.update(output=self.output)
176184

185+
if self.outsuffix is not None:
186+
kwargs.update(outsuffix=self.outsuffix)
187+
177188
self.testRunner = self.testRunner(**kwargs)
178189
super(XMLTestProgram, self).runTests()
179190
finally:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /