allura
Revision | 17bd86bafacb56f1b2a67c477a00b4dc7cde30a6 (tree) |
---|---|
Time | 2012-06-07 23:58:56 |
Author | bolkimen <bolkimen@yaho...> |
Commiter | bolkimen |
ticket:66 add pyflakes
@@ -85,11 +85,14 @@ def test_no_tabs(): | ||
85 | 85 | if run(find_py + " | xargs grep ' ' ") not in [1,123]: |
86 | 86 | raise Exception('These should not use tab chars') |
87 | 87 | |
88 | -def test_pep8(): | |
88 | +def code_check(cmd_app, sample_file_name, work_file_name): | |
89 | 89 | samples_dir = pkg_resources.resource_filename( |
90 | 90 | 'alluratest', 'data') |
91 | - pep8_sample_path = os.path.join(samples_dir, 'pep8_sample.txt') | |
92 | - pep8_work_path = os.path.join(samples_dir, 'pep8_work.txt') | |
91 | + if not os.path.exists(samples_dir): | |
92 | + os.makedirs(samples_dir) | |
93 | + | |
94 | + pep8_sample_path = os.path.join(samples_dir, sample_file_name) | |
95 | + pep8_work_path = os.path.join(samples_dir, work_file_name) | |
93 | 96 | |
94 | 97 | initialize_mode = True |
95 | 98 | if os.path.isfile(pep8_sample_path): |
@@ -112,7 +115,7 @@ def test_pep8(): | ||
112 | 115 | all_files = [f for f in find_stdout.split('\n') |
113 | 116 | if '/migrations/' not in f and f.strip()] |
114 | 117 | for files in grouper(20, all_files, fillvalue=''): |
115 | - cmd = "pep8 " + ' '.join(files) | |
118 | + cmd = cmd_app + " " + ' '.join(files) | |
116 | 119 | retval, stdout, stderr = run_with_output(cmd) |
117 | 120 | |
118 | 121 | if initialize_mode: |
@@ -135,35 +138,12 @@ def test_pep8(): | ||
135 | 138 | sys.stdout.write("%s\n" % l) |
136 | 139 | error = True |
137 | 140 | if error: |
138 | - raise Exception('pep8 failure, see stdout') | |
141 | + raise Exception('%s failure, see stdout' % cmd_app) | |
139 | 142 | else: |
140 | 143 | shutil.copyfile(pep8_work_path, pep8_sample_path) |
141 | 144 | |
142 | -def test_pylint(): | |
143 | - # TODO | |
144 | - return | |
145 | - samples_dir = pkg_resources.resource_filename( | |
146 | - 'alluratest', 'tests/data') | |
147 | - pep8_sample_path = os.path.join(samples_dir, 'pep8_sample.txt') | |
148 | - run_with_output() | |
149 | - assert False | |
150 | - """ | |
151 | - proc = Popen(find_py, shell=True, cwd=toplevel_dir, stdout=PIPE, stderr=PIPE) | |
152 | - (find_stdout, stderr) = proc.communicate() | |
153 | - sys.stderr.write(stderr) | |
154 | - assert proc.returncode == 0, proc.returncode | |
155 | - | |
156 | - error = False | |
157 | - all_files = [f for f in find_stdout.split('\n') | |
158 | - if '/migrations/' not in f and f.strip()] | |
159 | - for files in grouper(20, all_files, fillvalue=''): | |
160 | - cmd = "pylint -e " + ' '.join(files) | |
161 | - retval = run(cmd) | |
162 | - if retval == 1: | |
163 | ||
164 | - #print 'Command was: %s' % cmd | |
165 | - print 'Returned %s' % retval | |
166 | - error = True | |
145 | +def test_pep8(): | |
146 | + code_check('pep8', 'pep8_sample.txt', 'pep8_work.txt') | |
167 | 147 | |
168 | - assert False | |
169 | - """ | |
148 | +def test_pyflakes(): | |
149 | + code_check('pyflakes', 'pyflakes_sample.txt', 'pyflakes_work.txt') |