summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2014-11-16 00:53:47 +0200
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2014-11-16 00:53:47 +0200
commitedac048269da24c085dbab79c0cebd52d8474298 (patch)
treed56261a9bbc755d68dd3178ea66054cf952d1c85
parent2463787cccad9d7eae91f128dc6cc3c9f6ad0324 (diff)
downloadpylint-edac048269da24c085dbab79c0cebd52d8474298.tar.gz
Add support for using both --jobs and -m switch on Windows and Python 2.
-rw-r--r--lint.py14
-rw-r--r--test/test_self.py3
2 files changed, 13 insertions, 4 deletions
diff --git a/lint.py b/lint.py
index 934abfa..193a514 100644
--- a/lint.py
+++ b/lint.py
@@ -649,7 +649,19 @@ class PyLinter(OptionsManagerMixIn, MessagesHandlerMixIn, ReportsHandlerMixIn,
if self.config.jobs == 1:
self._do_check(files_or_modules)
else:
- self._parallel_check(files_or_modules)
+ # Hack that permits running pylint, on Windows, with -m switch
+ # and with --jobs, as in 'py -2 -m pylint .. --jobs'.
+ # For more details why this is needed,
+ # see Python issue http://bugs.python.org/issue10845.
+
+ mock_main = six.PY2 and __name__ != '__main__' # -m switch
+ if mock_main:
+ sys.modules['__main__'] = sys.modules[__name__]
+ try:
+ self._parallel_check(files_or_modules)
+ finally:
+ if mock_main:
+ sys.modules.pop('__main__')
def _parallel_task(self, files_or_modules):
# Prepare configuration for child linters.
diff --git a/test/test_self.py b/test/test_self.py
index ef5de96..57f4701 100644
--- a/test/test_self.py
+++ b/test/test_self.py
@@ -131,9 +131,6 @@ class RunTC(unittest.TestCase):
self._runtest([join(HERE, 'regrtest_data/no_stdout_encoding.py')],
out=strio)
- @unittest.skipIf(sys.platform.startswith("win") and sys.version_info[0] == 2,
- "This test does not work on Python 2.X due to a bug in "
- "multiprocessing.")
def test_parallel_execution(self):
self._runtest(['-j 2', 'pylint/test/functional/arguments.py',
'pylint/test/functional/bad_continuation.py'], code=1)