diff options
author | Reverb C <reverbc@users.noreply.github.com> | 2018-03-01 16:55:05 +0800 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-07-16 09:37:56 +0200 |
commit | 0d913675ec682401b2814bb2a8ae06a66f22ebbd (patch) | |
tree | 42d24bfbcde96fe9e46b8398041c84bd05234f23 | |
parent | d6cc00063dfd21ee386c3f9e99272b06cb746922 (diff) | |
download | pylint-git-0d913675ec682401b2814bb2a8ae06a66f22ebbd.tar.gz |
Correctly strip the path prefix from the report paths (#1883)
Closes #1120
-rw-r--r-- | CONTRIBUTORS.txt | 4 | ||||
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pylint/test/test_import_graph.py | 2 | ||||
-rw-r--r-- | pylint/test/test_regr.py | 2 | ||||
-rw-r--r-- | pylint/test/test_self.py | 20 | ||||
-rw-r--r-- | pylint/test/unittest_lint.py | 8 | ||||
-rw-r--r-- | pylint/utils.py | 2 |
7 files changed, 36 insertions, 7 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index c501c6322..a720347ea 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -157,3 +157,7 @@ Order doesn't matter (not that much, at least ;) Added new py3k check invalid-unicode-literal. * Adam Dangoor: contributor +* Reverb Chu: contributor + +* Tobias Hernstig: contributor + @@ -8,6 +8,11 @@ What's New in Pylint 1.9.3? Release date: |TBA| + * Fix incorrect file path when file absolute path contains multiple ``path_strip_prefix`` strings. + + Close #1120 and #2280 + + * `in` is considered iterating context for some of the Python 3 porting checkers Close #2186 diff --git a/pylint/test/test_import_graph.py b/pylint/test/test_import_graph.py index e1938174e..d45d5fd5e 100644 --- a/pylint/test/test_import_graph.py +++ b/pylint/test/test_import_graph.py @@ -62,7 +62,7 @@ def remove_files(): pass -@pytest.mark.usefixture("remove_files") +@pytest.mark.usefixtures("remove_files") def test_checker_dep_graphs(linter): l = linter l.global_set_option('persistent', False) diff --git a/pylint/test/test_regr.py b/pylint/test/test_regr.py index d85b0d8a6..d231c352a 100644 --- a/pylint/test/test_regr.py +++ b/pylint/test/test_regr.py @@ -100,7 +100,7 @@ def modify_path(): os.chdir(cwd) -@pytest.mark.usefixture("modify_path") +@pytest.mark.usefixtures("modify_path") def test_check_package___init__(finalize_linter): filename = 'package.__init__' finalize_linter.check(filename) diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py index 8e2e564d5..b77988105 100644 --- a/pylint/test/test_self.py +++ b/pylint/test/test_self.py @@ -458,3 +458,23 @@ class TestRunTC(object): module = join(HERE, 'regrtest_data', 'application_crash.py') with _configure_lc_ctype('UTF-8'): self._test_output([module, '-E'], expected_output=expected_output) + + @pytest.mark.skipif(sys.platform == 'win32', reason='only occurs on *nix') + def test_parseable_file_path(self): + file_name = 'test_target.py' + fake_path = HERE + os.getcwd() + module = join(fake_path, file_name) + + try: + # create module under directories which have the same name as reporter.path_strip_prefix + # e.g. /src/some/path/src/test_target.py when reporter.path_strip_prefix = /src/ + os.makedirs(fake_path) + with open(module, 'w') as test_target: + test_target.write('a = object()') + + self._test_output( + [module, '--output-format=parseable'], + expected_output=join(os.getcwd(), file_name)) + finally: + os.remove(module) + os.removedirs(fake_path) diff --git a/pylint/test/unittest_lint.py b/pylint/test/unittest_lint.py index 2b2a341a9..5744ad523 100644 --- a/pylint/test/unittest_lint.py +++ b/pylint/test/unittest_lint.py @@ -532,7 +532,7 @@ def pop_pylintrc(): os.environ.pop('PYLINTRC', None) -@pytest.mark.usefixture("pop_pylintrc") +@pytest.mark.usefixtures("pop_pylintrc") def test_pylint_home(): uhome = os.path.expanduser('~') if uhome == '~': @@ -559,7 +559,7 @@ def test_pylint_home(): @pytest.mark.skipif(PYPY_VERSION_INFO, reason="TOX runs this test from within the repo and finds " "the project's pylintrc.") -@pytest.mark.usefixture("pop_pylintrc") +@pytest.mark.usefixtures("pop_pylintrc") def test_pylintrc(): with fake_home(): current_dir = getcwd() @@ -576,7 +576,7 @@ def test_pylintrc(): reload_module(config) -@pytest.mark.usefixture("pop_pylintrc") +@pytest.mark.usefixtures("pop_pylintrc") def test_pylintrc_parentdir(): with tempdir() as chroot: @@ -596,7 +596,7 @@ def test_pylintrc_parentdir(): assert config.find_pylintrc() == expected -@pytest.mark.usefixture("pop_pylintrc") +@pytest.mark.usefixtures("pop_pylintrc") def test_pylintrc_parentdir_no_package(): with tempdir() as chroot: with fake_home(): diff --git a/pylint/utils.py b/pylint/utils.py index 9c078eba8..e4fd0b95c 100644 --- a/pylint/utils.py +++ b/pylint/utils.py @@ -436,7 +436,7 @@ class MessagesHandlerMixIn(object): else: module, obj = get_module_and_frameid(node) abspath = node.root().file - path = abspath.replace(self.reporter.path_strip_prefix, '') + path = abspath.replace(self.reporter.path_strip_prefix, '', 1) # add the message self.reporter.handle_message( Message(msgid, symbol, |