From da2b0b8a43d7765b4e64e43365406d9678791975 Mon Sep 17 00:00:00 2001 From: Michael McNeil Forbes Date: Sun, 8 Mar 2015 21:13:01 -0700 Subject: [PATCH 1/3] Added test demonstrating issue #39 --- flake8/tests/test_main.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 flake8/tests/test_main.py diff --git a/flake8/tests/test_main.py b/flake8/tests/test_main.py new file mode 100644 index 0000000..29cabbb --- /dev/null +++ b/flake8/tests/test_main.py @@ -0,0 +1,38 @@ +from __future__ import with_statement + +import unittest +try: + from unittest import mock +except ImportError: + import mock # < PY33 + +import setuptools +from flake8 import main + + +class TestMain(unittest.TestCase): + def setUp(self): + self.patches = {} + + def tearDown(self): + assert len(self.patches.items()) == 0 + + def start_patch(self, patch): + self.patches[patch] = mock.patch(patch) + return self.patches[patch].start() + + def stop_patches(self): + patches = self.patches.copy() + for k, v in patches.items(): + v.stop() + del(self.patches[k]) + + def test_issue_39_regression(self): + distribution = setuptools.Distribution() + cmd = main.Flake8Command(distribution) + cmd.options_dict = {} + cmd.run() + + +if __name__ == '__main__': + unittest.main() From 1fd8b661749f90b51299fbc733a8e7fe7021968b Mon Sep 17 00:00:00 2001 From: Michael McNeil Forbes Date: Sun, 8 Mar 2015 21:13:54 -0700 Subject: [PATCH 2/3] Fix issue #39. --- CONTRIBUTORS.txt | 3 ++- flake8/main.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index ad54a21..140b430 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -19,4 +19,5 @@ Contributors (by order of appearance) : - Marc Labbé - Bruno Miguel Custódio - Florent Xicluna -- Austin Morton \ No newline at end of file +- Austin Morton +- Michael McNeil Forbes diff --git a/flake8/main.py b/flake8/main.py index 03d04b4..a11e137 100644 --- a/flake8/main.py +++ b/flake8/main.py @@ -134,4 +134,5 @@ class Flake8Command(setuptools.Command): # Run the checkers report = flake8_style.check_files() exit_code = print_report(report, flake8_style) - raise SystemExit(exit_code > 0) + if exit_code > 0: + raise SystemExit(exit_code > 0) From dca5551156a047841fe4b894f4d8dd939567b5a4 Mon Sep 17 00:00:00 2001 From: Michael McNeil Forbes Date: Mon, 9 Mar 2015 11:27:15 -0700 Subject: [PATCH 3/3] Removed some unused testing code. --- flake8/tests/test_main.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/flake8/tests/test_main.py b/flake8/tests/test_main.py index 29cabbb..af08093 100644 --- a/flake8/tests/test_main.py +++ b/flake8/tests/test_main.py @@ -1,32 +1,12 @@ from __future__ import with_statement import unittest -try: - from unittest import mock -except ImportError: - import mock # < PY33 import setuptools from flake8 import main class TestMain(unittest.TestCase): - def setUp(self): - self.patches = {} - - def tearDown(self): - assert len(self.patches.items()) == 0 - - def start_patch(self, patch): - self.patches[patch] = mock.patch(patch) - return self.patches[patch].start() - - def stop_patches(self): - patches = self.patches.copy() - for k, v in patches.items(): - v.stop() - del(self.patches[k]) - def test_issue_39_regression(self): distribution = setuptools.Distribution() cmd = main.Flake8Command(distribution)