From f478bd59c5bf4d938c834505c6d10bfac6b81855 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 8 Jan 2013 11:08:56 -0500 Subject: [PATCH] Add a test to the scaffold project buildout that ensures pep8 passes. --- .../+package+/tests/test_functional.py_tmpl | 5 ++- pecan/tests/test_scaffolds.py | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/pecan/scaffolds/base/+package+/tests/test_functional.py_tmpl b/pecan/scaffolds/base/+package+/tests/test_functional.py_tmpl index beb89ee..2d7c6f0 100644 --- a/pecan/scaffolds/base/+package+/tests/test_functional.py_tmpl +++ b/pecan/scaffolds/base/+package+/tests/test_functional.py_tmpl @@ -12,7 +12,10 @@ class TestRootController(FunctionalTest): def test_search(self): response = self.app.post('/', params={'q': 'RestController'}) assert response.status_int == 302 - assert response.headers['Location'] == 'http://pecan.readthedocs.org/en/latest/search.html?q=RestController' + assert response.headers['Location'] == ( + 'http://pecan.readthedocs.org/en/latest/search.html' + '?q=RestController' + ) def test_get_not_found(self): response = self.app.get('/a/bogus/url', expect_errors=True) diff --git a/pecan/tests/test_scaffolds.py b/pecan/tests/test_scaffolds.py index 0dc916c..de99807 100644 --- a/pecan/tests/test_scaffolds.py +++ b/pecan/tests/test_scaffolds.py @@ -322,3 +322,34 @@ class TestTemplateBuilds(unittest.TestCase): proc.wait() assert proc.stderr.read().splitlines()[-1].strip() == 'OK' + + @unittest.skipUnless(has_internet(), 'Internet connectivity unavailable.') + @unittest.skipUnless( + getattr(pecan, '__run_all_tests__', False) is True, + 'Skipping (slow). To run, `$ python setup.py test --functional.`' + ) + def test_project_passes_pep8(self): + # Install pep8 + pip_exe = os.path.join(self.install_dir, 'bin', 'pip') + proc = subprocess.Popen([ + pip_exe, + 'install', + 'pep8' + ]) + proc.wait() + + # Run pep8 on setup.py and the project + pep8_exe = os.path.join(self.install_dir, 'bin', 'pep8') + proc = subprocess.Popen([ + pep8_exe, + 'setup.py', + 'testing123' + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + proc.wait() + + # No output == good + output = proc.stdout.read() + assert output == ''