filter-subunit: default to empty affixes, saving verbose checks
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Mon, 1 Aug 2016 23:00:27 +0000 (11:00 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 31 Aug 2016 05:09:26 +0000 (07:09 +0200)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
selftest/filter-subunit
selftest/subunithelper.py

index fe157a0ec52b4eb2c01071109dea2f23bd1e2ce4..857b8420eade5ad62c08938d06f316eab6f42806 100755 (executable)
@@ -36,9 +36,9 @@ parser.add_option("--strip-passed-output", action="store_true",
     help="Whether to strip output from tests that passed")
 parser.add_option("--fail-immediately", action="store_true",
     help="Whether to stop on the first error", default=False)
-parser.add_option("--prefix", type="string",
+parser.add_option("--prefix", type="string", default='',
     help="Add prefix to all test names")
-parser.add_option("--suffix", type="string",
+parser.add_option("--suffix", type="string", default='',
     help="Add suffix to all test names")
 parser.add_option("--fail-on-empty", default=False,
     action="store_true", help="Fail if there was no subunit output")
@@ -47,14 +47,8 @@ parser.add_option("--list", default=False,
 opts, args = parser.parse_args()
 
 if opts.list:
-    prefix = opts.prefix
-    suffix = opts.suffix
-    if not prefix:
-        prefix = ""
-    if not suffix:
-        suffix = ""
     for l in sys.stdin:
-         sys.stdout.write("%s%s%s\n" % (prefix, l.rstrip(), suffix))
+         sys.stdout.write("%s%s%s\n" % (opts.prefix, l.rstrip(), opts.suffix))
     sys.exit(0)
 
 if opts.expected_failures:
index 441bafad926641b0f7ff0407278aac39c384c807..a3bb30b69bcdd536bf6b9019cc080e0de1466662 100644 (file)
@@ -287,14 +287,7 @@ class FilterOps(unittest.TestResult):
         self._ops.startTest(test)
 
     def _add_prefix(self, test):
-        prefix = ""
-        suffix = ""
-        if self.prefix is not None:
-            prefix = self.prefix
-        if self.suffix is not None:
-            suffix = self.suffix
-
-        return subunit.RemotedTestCase(prefix + test.id() + suffix)
+        return subunit.RemotedTestCase(self.prefix + test.id() + self.suffix)
 
     def addError(self, test, err=None):
         test = self._add_prefix(test)