[BUG] Relative import false negatives
Describe the bug
If ./src/foo/tests/__init__.py defines a project-specific base test case class:
class FooTestCase(unittest.TestCase):
And then an actual test module uses a relative import to use that base class:
from .. import tests
class BarTests(tests.FooTestCase):
Running $ pylint ./src/foo directly doesn't report any error but running $ prospector ./src/foo reports pylint: relative-beyond-top-level / Attempted relative import beyond top-level package.
To Reproduce Steps to reproduce the behavior:
$ prospector ./src/foo
Expected behavior
Prospector should report no errors the same as running PyLint directly does.
Environment:
- OS: Docker
python:3.11image - Tool: pylint
- Prospector version: v1.9.0
- Python version: v3.11.2
Additional context
I've also observed this with from . import bar relative imports so I think the issue is a general issue with relative imports and not specific to just the given example case.
May be related to my other Prospector issue. It seems like Prospector may be stripping some context or not providing some context that PyLint uses to identify package hierarchy, class hierarchy, etc..