diff --git a/test/test_api.py b/test/test_api.py new file mode 100644 index 00000000..f63f90c0 --- /dev/null +++ b/test/test_api.py @@ -0,0 +1,23 @@ +import jedi +from jedi import common + + +def test_preload_modules(): + def check_loaded(*modules): + # + 1 for builtin, +1 for None module (currently used) + assert len(new) == len(modules) + 2 + for i in modules + ('__builtin__',): + assert [i in k for k in new.keys() if k is not None] + + from jedi import cache + temp_cache, cache.parser_cache = cache.parser_cache, {} + new = cache.parser_cache + with common.ignored(KeyError): # performance of tests -> no reload + new['__builtin__'] = temp_cache['__builtin__'] + + jedi.preload_module('datetime') + check_loaded('datetime') + jedi.preload_module('json', 'token') + check_loaded('datetime', 'json', 'token') + + cache.parser_cache = temp_cache diff --git a/test/test_regression.py b/test/test_regression.py index ea0bee4a..cf6ff77b 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -347,28 +347,6 @@ class TestRegression(TestBase): assert self.completions(s) -class TestFeature(TestBase): - def test_preload_modules(self): - def check_loaded(*modules): - # + 1 for builtin, +1 for None module (currently used) - assert len(new) == len(modules) + 2 - for i in modules + ('__builtin__',): - assert [i in k for k in new.keys() if k is not None] - - from jedi import cache - temp_cache, cache.parser_cache = cache.parser_cache, {} - new = cache.parser_cache - with common.ignored(KeyError): # performance of tests -> no reload - new['__builtin__'] = temp_cache['__builtin__'] - - jedi.preload_module('datetime') - check_loaded('datetime') - jedi.preload_module('json', 'token') - check_loaded('datetime', 'json', 'token') - - cache.parser_cache = temp_cache - - def test_settings_module(): """ jedi.settings and jedi.cache.settings must be the same module. @@ -419,7 +397,3 @@ def test_no_duplicate_modules(): # module could have a function with the same name, e.g. # `keywords.keywords`. assert imported is tm - - -if __name__ == '__main__': - unittest.main()