forked from VimPlug/jedi
clean out the last_* fields of sys before importing it.
The system gets confused if there were uncaught errors in previous tests without this. Particularly, it crashes (at least 2.6) if any tests during test_integrations were skipped.
This commit is contained in:
@@ -9,6 +9,13 @@ from jedi._compatibility import is_py3
|
|||||||
from pytest import raises
|
from pytest import raises
|
||||||
|
|
||||||
|
|
||||||
|
def _clear_last_exception_fields_in_sys():
|
||||||
|
import sys
|
||||||
|
sys.last_type = None
|
||||||
|
sys.last_value = None
|
||||||
|
sys.last_traceback = None
|
||||||
|
|
||||||
|
|
||||||
def test_preload_modules():
|
def test_preload_modules():
|
||||||
def check_loaded(*modules):
|
def check_loaded(*modules):
|
||||||
# +1 for None module (currently used)
|
# +1 for None module (currently used)
|
||||||
@@ -20,6 +27,7 @@ def test_preload_modules():
|
|||||||
temp_cache, cache.parser_cache = cache.parser_cache, {}
|
temp_cache, cache.parser_cache = cache.parser_cache, {}
|
||||||
parser_cache = cache.parser_cache
|
parser_cache = cache.parser_cache
|
||||||
|
|
||||||
|
_clear_last_exception_fields_in_sys()
|
||||||
api.preload_module('sys')
|
api.preload_module('sys')
|
||||||
check_loaded() # compiled (c_builtin) modules shouldn't be in the cache.
|
check_loaded() # compiled (c_builtin) modules shouldn't be in the cache.
|
||||||
api.preload_module('json', 'token')
|
api.preload_module('json', 'token')
|
||||||
|
|||||||
Reference in New Issue
Block a user