]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
describe-tests: fix formatting for flake8
authorJosh Durgin <jdurgin@redhat.com>
Thu, 10 Dec 2015 00:54:28 +0000 (16:54 -0800)
committerJosh Durgin <jdurgin@redhat.com>
Thu, 10 Dec 2015 00:54:28 +0000 (16:54 -0800)
Signed-off-by: Josh Durgin <jdurgin@redhat.com>
teuthology/describe_tests.py
teuthology/test/fake_fs.py
teuthology/test/test_describe_tests.py

index 858e23742b3a6e04e3df88066e1daac7be36edf0..5c5d20c8a4dabee4f1deabb253b34246a520fca8 100644 (file)
@@ -10,12 +10,14 @@ import yaml
 from teuthology.exceptions import ParseError
 from teuthology.suite import build_matrix, combine_path
 
+
 def main(args):
     try:
         describe_tests(args)
     except ParseError:
         sys.exit(1)
 
+
 def describe_tests(args):
     suite_dir = os.path.abspath(args["<suite_dir>"])
     fields = args["--fields"].split(',')
@@ -44,6 +46,7 @@ def describe_tests(args):
 
     output_results(headers, rows, output_format, hrule)
 
+
 def output_results(headers, rows, output_format, hrule):
     """Write the headers and rows given in the specified output format to
     stdout.
@@ -64,6 +67,7 @@ def output_results(headers, rows, output_format, hrule):
             table.add_row(row)
         print(table)
 
+
 def get_combinations(suite_dir, fields, subset,
                      limit, filter_in, filter_out,
                      include_facet, _isdir=os.path.isdir, _open=open,
@@ -148,6 +152,7 @@ def get_combinations(suite_dir, fields, subset,
     return headers, sorted([[row.get(field, '') for field in headers]
                             for row in rows])
 
+
 def describe_suite(suite_dir, fields, include_facet, output_format):
     """Describe a suite listing each subdirectory and file once as a separate
     row.
@@ -163,6 +168,7 @@ def describe_suite(suite_dir, fields, include_facet, output_format):
         headers.append('facet')
     return headers + fields, rows
 
+
 def extract_info(file_name, fields, _isdir=os.path.isdir, _open=open):
     """Read a yaml file and return a dictionary mapping the fields to the
     values of those fields in the file.
@@ -204,6 +210,7 @@ def extract_info(file_name, fields, _isdir=os.path.isdir, _open=open):
 
     return {field: meta[0].get(field, '') for field in fields}
 
+
 def path_relative_to_suites(path):
     """Attempt to trim the ceph-qa-suite root directory from the beginning
     of a path.
@@ -214,6 +221,7 @@ def path_relative_to_suites(path):
     except ValueError:
         return path
 
+
 def tree_with_info(cur_dir, fields, include_facet, prefix, rows,
                    _listdir=os.listdir, _isdir=os.path.isdir,
                    _open=open, output_format='plain'):
index 4290a821bd90fc917b2720b5a00b03cadc99aebe..161342158457f5df6eef3eb24f75dcf09519628c 100644 (file)
@@ -8,21 +8,21 @@ def make_fake_fstools(fake_filesystem):
     os.isdir() and os.isfile()
 
     An example fake_filesystem value:
-        >>> fake_fs = {
-            'a_directory': {
-                'another_directory': {
-                    'empty_file': None,
-                    'another_empty_file': None,
-                },
-                'random_file': None,
-                'yet_another_directory': {
-                    'empty_directory': {},
-                },
-                'file_with_contents': 'data',
-            },
+        >>> fake_fs = {\
+            'a_directory': {\
+                'another_directory': {\
+                    'empty_file': None,\
+                    'another_empty_file': None,\
+                },\
+                'random_file': None,\
+                'yet_another_directory': {\
+                    'empty_directory': {},\
+                },\
+                'file_with_contents': 'data',\
+            },\
         }
-
-        >>> fake_listdir = make_fake_listdir(fake_fs)
+        >>> fake_listdir, fake_isfile, _, _ = \
+                make_fake_fstools(fake_fs)
         >>> fake_listdir('a_directory/yet_another_directory')
         ['empty_directory']
         >>> fake_isfile('a_directory/yet_another_directory')
index 145fc7acec1f58bda452f6e68de542837ca167f9..411ccbc3c7f50395d4577c5ce2dc528d1fdf1c64 100644 (file)
@@ -118,7 +118,7 @@ class TestDescribeTests(object):
         rows = tree_with_info('basic', [], False, '', [],
                               self.fake_listdir, self.fake_isdir,
                               self.fake_open)
-        assert rows == [ [x] for x in expected_tree]
+        assert rows == [[x] for x in expected_tree]
 
     def test_single_filter(self):
         rows = tree_with_info('basic', ['desc'], False, '', [],
@@ -171,7 +171,6 @@ class TestDescribeTests(object):
                                      expected_rbd_features,
                                      expected_desc))
 
-
     def test_multiple_filters_with_facets(self):
         rows = tree_with_info('basic', ['desc', 'rbd_features'], True,
                               '', [], self.fake_listdir,
@@ -190,9 +189,11 @@ class TestDescribeTests(object):
                                      expected_desc))
 
     def test_combinations_only_facets(self):
-        headers, rows = get_combinations('basic', [], None, 1, None, None, True,
+        headers, rows = get_combinations('basic', [], None, 1, None,
+                                         None, True,
                                          self.fake_isdir, self.fake_open,
-                                         self.fake_isfile, self.fake_listdir)
+                                         self.fake_isfile,
+                                         self.fake_listdir)
         self.assert_expected_combo_headers(headers)
         assert rows == [['basic', 'install', 'fixed-1', 'rbd_api_tests']]
 
@@ -200,10 +201,15 @@ class TestDescribeTests(object):
         headers, rows = get_combinations('basic', ['desc', 'rbd_features'],
                                          None, 1, None, None, False,
                                          self.fake_isdir, self.fake_open,
-                                         self.fake_isfile, self.fake_listdir)
+                                         self.fake_isfile,
+                                         self.fake_listdir)
         assert headers == ['desc', 'rbd_features']
-        assert rows == [['install ceph\nsingle node cluster\nc/c++ librbd api tests with default settings',
-                         'default']]
+        descriptions = '\n'.join([
+            'install ceph',
+            'single node cluster',
+            'c/c++ librbd api tests with default settings',
+        ])
+        assert rows == [[descriptions, 'default']]
 
     def test_combinations_filter_in(self):
         headers, rows = get_combinations('basic', [], None, 0, ['old_format'],
@@ -211,7 +217,8 @@ class TestDescribeTests(object):
                                          self.fake_isdir, self.fake_open,
                                          self.fake_isfile, self.fake_listdir)
         self.assert_expected_combo_headers(headers)
-        assert rows == [['basic', 'install', 'fixed-1', 'rbd_api_tests_old_format']]
+        assert rows == [['basic', 'install', 'fixed-1',
+                         'rbd_api_tests_old_format']]
 
     def test_combinations_filter_out(self):
         headers, rows = get_combinations('basic', [], None, 0, None,
@@ -234,21 +241,26 @@ def test_extract_info_dir():
     info = extract_info('a/b.yaml', ['foo', 'bar'], fake_isdir, fake_open)
     assert info == {'foo': 'c', 'bar': ''}
 
+
 def check_parse_error(fs):
     _, _, fake_isdir, fake_open = make_fake_fstools(fs)
     with pytest.raises(ParseError):
         a = extract_info('a.yaml', ['a'], fake_isdir, fake_open)
         raise Exception(str(a))
 
+
 def test_extract_info_too_many_elements():
     check_parse_error({'a.yaml': 'meta: [{a: b}, {b: c}]'})
 
+
 def test_extract_info_not_a_list():
     check_parse_error({'a.yaml': 'meta: {a: b}'})
 
+
 def test_extract_info_not_a_dict():
     check_parse_error({'a.yaml': 'meta: [[a, b]]'})
 
+
 def test_extract_info_empty_file():
     simple_fs = {'a.yaml': ''}
     _, _, fake_isdir, fake_open = make_fake_fstools(simple_fs)