Skip to content

Commit

Permalink
Extend cwd patching to func_w0401_package test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Jul 13, 2022
1 parent 916e556 commit 6fa6e74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/messages/func_w0401_package.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
R: 1: Cyclic import (tests.input.func_w0401_package.all_the_things -> tests.input.func_w0401_package.thing2)
R: 1: Cyclic import (input.func_w0401_package.all_the_things -> input.func_w0401_package.thing2)
W: 8: Using a conditional statement with a constant value
12 changes: 9 additions & 3 deletions tests/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

from pylint.testutils import UPDATE_FILE, UPDATE_OPTION, _get_tests_info, linter
from pylint.testutils.reporter_for_tests import GenericTestReporter
from pylint.testutils.utils import _test_cwd

INPUT_DIR = join(dirname(abspath(__file__)), "input")
MSG_DIR = join(dirname(abspath(__file__)), "messages")
TESTS_DIR = dirname(abspath(__file__))
INPUT_DIR = join(TESTS_DIR, "input")
MSG_DIR = join(TESTS_DIR, "messages")


FILTER_RGX = None
Expand Down Expand Up @@ -46,7 +48,11 @@ def _test_functionality(self) -> None:
tocheck += [
self.package + f".{name.replace('.py', '')}" for name, _ in self.depends
]
self._test(tocheck)
# given that TESTS_DIR could be treated as a namespace package
# when under the current directory, cd to it so that "tests." is not
# prepended to module names in the output of cyclic-import
with _test_cwd(TESTS_DIR):
self._test(tocheck)

def _check_result(self, got: str) -> None:
error_msg = (
Expand Down

0 comments on commit 6fa6e74

Please sign in to comment.