PEP8 fixes.
authorThomi Richards <thomi.richards@canonical.com>
Tue, 19 Nov 2013 01:54:02 +0000 (14:54 +1300)
committerThomi Richards <thomi.richards@canonical.com>
Tue, 19 Nov 2013 01:54:02 +0000 (14:54 +1300)
python/subunit/_output.py
python/subunit/tests/test_output_filter.py

index fe4585f8e2dbec94e2097b29f348003c742fd588..e3f3bc4d8eaa187cff5e28ac0be433f76f40be84 100644 (file)
@@ -21,6 +21,7 @@ from string import split
 
 from subunit.v2 import StreamResultToBytes
 
+
 def output_main():
     args = parse_arguments()
     output = get_output_stream_writer()
@@ -59,8 +60,8 @@ def parse_arguments(args=None, ParserClass=ArgumentParser):
     )
     common_args.add_argument(
         "--mimetype",
-        help="The mime type to send with this file. This is only used if the "\
-        "--attach-file argument is used. This argument is optional. If it is "\
+        help="The mime type to send with this file. This is only used if the "
+        "--attach-file argument is used. This argument is optional. If it is "
         "not specified, the file will be sent wihtout a mime type.",
         default=None
     )
@@ -76,7 +77,7 @@ def parse_arguments(args=None, ParserClass=ArgumentParser):
         description="These actions are supported by this tool",
     )
 
-    final_state = "This is a final action: No more actions may be generated " \
+    final_state = "This is a final action: No more actions may be generated "\
         "for this test id after this one."
 
     parser_start = sub_parsers.add_parser(
@@ -111,15 +112,15 @@ def parse_arguments(args=None, ParserClass=ArgumentParser):
 
     parser_expected_fail = sub_parsers.add_parser(
         "expected-fail",
-        help="Marks a test as failing expectedly (this is not counted as a "\
-            "failure). " + final_state,
+        help="Marks a test as failing expectedly (this is not counted as a "
+        "failure). " + final_state,
         parents=[common_args],
     )
 
     parser_unexpected_success = sub_parsers.add_parser(
         "unexpected-success",
-        help="Marks a test as succeeding unexpectedly (this is counted as a "\
-            "failure). " + final_state,
+        help="Marks a test as succeeding unexpectedly (this is counted as a "
+        "failure). " + final_state,
         parents=[common_args],
     )
 
@@ -162,7 +163,7 @@ def generate_bytestream(args, output_writer):
 
 
 def write_chunked_file(file_obj, test_id, output_writer, chunk_size=1024,
-    mime_type=None):
+                       mime_type=None):
     reader = partial(file_obj.read, chunk_size)
     for chunk in iter(reader, ''):
         output_writer.status(
@@ -173,23 +174,25 @@ def write_chunked_file(file_obj, test_id, output_writer, chunk_size=1024,
             eof=False,
         )
     output_writer.status(
-            test_id=test_id,
-            file_name=file_obj.name,
-            file_bytes='',
-            mime_type=mime_type,
-            eof=True,
-        )
+        test_id=test_id,
+        file_name=file_obj.name,
+        file_bytes='',
+        mime_type=mime_type,
+        eof=True,
+    )
 
 
 _ZERO = datetime.timedelta(0)
 
 
 class UTC(datetime.tzinfo):
-    """UTC"""
+
     def utcoffset(self, dt):
         return _ZERO
+
     def tzname(self, dt):
         return "UTC"
+
     def dst(self, dt):
         return _ZERO
 
index 2a70a2c50920e1d72e0b843fa568b8b831c04238..1359c46d6ce78f1737687ab99037443b697f1a45 100644 (file)
@@ -46,8 +46,10 @@ class SafeArgumentParser(argparse.ArgumentParser):
     """An ArgumentParser class that doesn't call sys.exit."""
 
     def exit(self, status=0, message=""):
-        raise RuntimeError("ArgumentParser requested to exit with status "\
-            " %d and message %r" % (status, message))
+        raise RuntimeError(
+            "ArgumentParser requested to exit with status %d and message %r"
+            % (status, message)
+        )
 
 
 safe_parse_arguments = partial(parse_arguments, ParserClass=SafeArgumentParser)
@@ -76,10 +78,22 @@ class OutputFilterArgumentParserTests(TestCase):
             self._test_command(command, self.getUniqueString())
 
     def test_command_translation(self):
-        self.assertThat(translate_command_name('start'), Equals('inprogress'))
-        self.assertThat(translate_command_name('pass'), Equals('success'))
-        self.assertThat(translate_command_name('expected-fail'), Equals('xfail'))
-        self.assertThat(translate_command_name('unexpected-success'), Equals('uxsuccess'))
+        self.assertThat(
+            translate_command_name('start'),
+            Equals('inprogress')
+        )
+        self.assertThat(
+            translate_command_name('pass'),
+            Equals('success')
+        )
+        self.assertThat(
+            translate_command_name('expected-fail'),
+            Equals('xfail')
+        )
+        self.assertThat(
+            translate_command_name('unexpected-success'),
+            Equals('uxsuccess')
+        )
         for command in ('fail', 'skip', 'exists'):
             self.assertThat(translate_command_name(command), Equals(command))
 
@@ -104,7 +118,7 @@ class OutputFilterArgumentParserTests(TestCase):
             args = safe_parse_arguments(
                 args=[command, 'foo', '--tags', "foo,bar,baz"]
             )
-            self.assertThat(args.tags, Equals(["foo","bar","baz"]))
+            self.assertThat(args.tags, Equals(["foo", "bar", "baz"]))
 
 
 class ByteStreamCompatibilityTests(TestCase):
@@ -252,7 +266,7 @@ class ByteStreamCompatibilityTests(TestCase):
             MatchesCall(
                 call='status',
                 test_id='foo',
-                test_tags=set(['hello','world']),
+                test_tags=set(['hello', 'world']),
                 timestamp=self._dummy_timestamp,
             )
         )
@@ -261,7 +275,7 @@ class ByteStreamCompatibilityTests(TestCase):
 class FileChunkingTests(TestCase):
 
     def _write_chunk_file(self, file_data, chunk_size, mimetype=None):
-        """Write chunked data to a subunit stream, return a StreamResult object."""
+        """Write file data to a subunit stream, get a StreamResult object."""
         stream = BytesIO()
         output_writer = StreamResultToBytes(output_stream=stream)
 
@@ -269,7 +283,13 @@ class FileChunkingTests(TestCase):
             f.write(file_data)
             f.seek(0)
 
-            write_chunked_file(f, 'foo_test', output_writer, chunk_size, mimetype)
+            write_chunked_file(
+                f,
+                'foo_test',
+                output_writer,
+                chunk_size,
+                mimetype
+            )
 
         stream.seek(0)
 
@@ -333,7 +353,9 @@ class MatchesCall(Matcher):
             try:
                 pos = self._position_lookup[k]
                 if call_tuple[pos] != v:
-                    return Mismatch("Value for key is %r, not %r" % (call_tuple[pos], v))
+                    return Mismatch(
+                        "Value for key is %r, not %r" % (call_tuple[pos], v)
+                    )
             except IndexError:
                 return Mismatch("Key %s is not present." % k)