<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import time
import functools
import itertools
import os

from base import TestBase

import jedi
from jedi._compatibility import is_py25, utf8, unicode
from jedi import api

#jedi.set_debug_function(jedi.debug.print_to_stdout)


class TestRegression(TestBase):
    def test_star_import_cache_duration(self):
        new = 0.01
        old, jedi.settings.star_import_cache_validity = \
                jedi.settings.star_import_cache_validity, new

        cache = jedi.cache
        cache.star_import_cache = {}  # first empty...
        # path needs to be not-None (otherwise caching effects are not visible)
        jedi.Script('', 1, 0, '').complete()
        time.sleep(2 * new)
        jedi.Script('', 1, 0, '').complete()

        # reset values
        jedi.settings.star_import_cache_validity = old
        length = len(cache.star_import_cache)
        cache.star_import_cache = {}<commit_msg>python 3 compatibility, which is nicer anyway<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import time
import functools
import itertools
import os

from base import TestBase

import jedi
from jedi._compatibility import is_py25, utf8, unicode
from jedi import api

#jedi.set_debug_function(jedi.debug.print_to_stdout)


class TestRegression(TestBase):
    def test_star_import_cache_duration(self):
        new = 0.01
        old, jedi.settings.star_import_cache_validity = \
                jedi.settings.star_import_cache_validity, new

        cache = api.cache
        cache.star_import_cache = {}  # first empty...
        # path needs to be not-None (otherwise caching effects are not visible)
        jedi.Script('', 1, 0, '').complete()
        time.sleep(2 * new)
        jedi.Script('', 1, 0, '').complete()

        # reset values
        jedi.settings.star_import_cache_validity = old
        length = len(cache.star_import_cache)
        cache.star_import_cache = {}
{'fraction_non_alphanumeric': 0.09924433249370278, 'fraction_numerical': 0.012594458438287154, 'mean_word_length': 2.964071856287425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5960158', 'n_tokens_mistral': 641, 'n_tokens_neox': 606, 'n_words': 154}