예제 #1
0
파일: test_api.py 프로젝트: ANtlord/jedi
def test_preload_modules():
    def check_loaded(*modules):
        # +1 for None module (currently used)
        assert len(parser_cache) == len(modules) + 1
        for i in modules:
            assert [i in k for k in parser_cache.keys() if k is not None]

    temp_cache, utils.parser_cache = utils.parser_cache, {}
    parser_cache = utils.parser_cache

    api.preload_module('sys')
    check_loaded()  # compiled (c_builtin) modules shouldn't be in the cache.
    api.preload_module('json', 'token')
    check_loaded('json', 'token')

    utils.parser_cache = temp_cache
예제 #2
0
파일: test_api.py 프로젝트: noscripter/jedi
def test_preload_modules():
    def check_loaded(*modules):
        # +1 for None module (currently used)
        assert len(parser_cache) == len(modules) + 1
        for i in modules:
            assert [i in k for k in parser_cache.keys() if k is not None]

    temp_cache, utils.parser_cache = utils.parser_cache, {}
    parser_cache = utils.parser_cache

    api.preload_module('sys')
    check_loaded()  # compiled (c_builtin) modules shouldn't be in the cache.
    api.preload_module('json', 'token')
    check_loaded('json', 'token')

    utils.parser_cache = temp_cache
예제 #3
0
파일: test_api.py 프로젝트: Shieh/jedi
def test_preload_modules():
    def check_loaded(*modules):
        # +1 for None module (currently used)
        grammar_cache = next(iter(cache.parser_cache.values()))
        assert len(grammar_cache) == len(modules) + 1
        for i in modules:
            assert [i in k for k in grammar_cache.keys() if k is not None]

    old_cache = cache.parser_cache.copy()
    cache.parser_cache.clear()

    try:
        api.preload_module('sys')
        check_loaded()  # compiled (c_builtin) modules shouldn't be in the cache.
        api.preload_module('types', 'token')
        check_loaded('types', 'token')
    finally:
        cache.parser_cache.update(old_cache)
예제 #4
0
def test_preload_modules():
    def check_loaded(*modules):
        # +1 for None module (currently used)
        grammar_cache = next(iter(cache.parser_cache.values()))
        assert len(grammar_cache) == len(modules) + 1
        for i in modules:
            assert [i in k for k in grammar_cache.keys() if k is not None]

    old_cache = cache.parser_cache.copy()
    cache.parser_cache.clear()

    try:
        api.preload_module('sys')
        check_loaded()  # compiled (c_builtin) modules shouldn't be in the cache.
        api.preload_module('types', 'token')
        check_loaded('types', 'token')
    finally:
        cache.parser_cache.update(old_cache)
예제 #5
0
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__']

    api.preload_module('datetime')
    check_loaded('datetime')
    api.preload_module('json', 'token')
    check_loaded('datetime', 'json', 'token')

    cache.parser_cache = temp_cache
예제 #6
0
파일: test_api.py 프로젝트: Ademan/jedi
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__']

    api.preload_module('datetime')
    check_loaded('datetime')
    api.preload_module('json', 'token')
    check_loaded('datetime', 'json', 'token')

    cache.parser_cache = temp_cache