mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Add absolute_import failing SSCCE, and get pytest to ignore it
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
addopts = --doctest-modules
|
addopts = --doctest-modules
|
||||||
|
|
||||||
# Ignore broken files in blackbox test directories
|
# Ignore broken files in blackbox test directories
|
||||||
norecursedirs = .* docs completion refactor
|
norecursedirs = .* docs completion refactor absolute_import
|
||||||
|
|
||||||
# Activate `clean_jedi_cache` fixture for all tests. This should be
|
# Activate `clean_jedi_cache` fixture for all tests. This should be
|
||||||
# fine as long as we are using `clean_jedi_cache` as a session scoped
|
# fine as long as we are using `clean_jedi_cache` as a session scoped
|
||||||
|
|||||||
13
test/absolute_import/local_module.py
Normal file
13
test/absolute_import/local_module.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
"""
|
||||||
|
This is a module that imports the *standard library* unittest,
|
||||||
|
despite there being a local "unittest" module. It specifies that it
|
||||||
|
wants the stdlib one with the ``absolute_import`` __future__ import.
|
||||||
|
|
||||||
|
The twisted equivalent of this module is ``twisted.trial._synctest``.
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import unittest # this is stdlib unittest, but jedi gets the local one
|
||||||
|
|
||||||
|
class Assertions(unittest.TestCase):
|
||||||
|
pass
|
||||||
9
test/absolute_import/minimal_demo.py
Normal file
9
test/absolute_import/minimal_demo.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import jedi
|
||||||
|
|
||||||
|
filename = "unittest.py"
|
||||||
|
with open(filename) as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
src = "".join(lines)
|
||||||
|
script = jedi.Script(src, len(lines), len(lines[1]), filename)
|
||||||
|
|
||||||
|
print script.completions()
|
||||||
13
test/absolute_import/unittest.py
Normal file
13
test/absolute_import/unittest.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
"""
|
||||||
|
This is a module that shadows a builtin (intentionally).
|
||||||
|
|
||||||
|
It imports a local module, which in turn imports stdlib unittest (the
|
||||||
|
name shadowed by this module). If that is properly resolved, there's
|
||||||
|
no problem. However, if jedi doesn't understand absolute_imports, it
|
||||||
|
will get this module again, causing infinite recursion.
|
||||||
|
"""
|
||||||
|
from local_module import Assertions
|
||||||
|
|
||||||
|
class TestCase(Assertions):
|
||||||
|
def test(self):
|
||||||
|
self.assertT
|
||||||
Reference in New Issue
Block a user