Esempio n. 1
0
    def test_extension_cache(self):
        #set and get the attribute
        rand = random.Random()
        value = rand.getrandbits(8)
        copyreg._extension_cache['cache1'] = value
        result = copyreg._extension_cache['cache1']
        self.assertTrue(result == value,
            "The get and set of the attribute failed")
        
        value = rand.getrandbits(16)
        copyreg._extension_cache['cache2'] = value
        result = copyreg._extension_cache['cache2']
        self.assertTrue(result == value,
            "The get and set of the attribute failed")

        #change the value of the attribue
        value2 = rand.getrandbits(4)
        copyreg._extension_cache['cache1'] = value2
        result = copyreg._extension_cache['cache1']
        self.assertTrue(result == value2,
            "The get and set of the attribute failed")
        
        if not copyreg._extension_cache.has_key('cache1') or  not copyreg._extension_cache.has_key('cache2'):
            Fail("Set of the attribute failed")
            
        copyreg.clear_extension_cache()
        if  copyreg._extension_cache.has_key('cache1') or copyreg._extension_cache.has_key('cache2'):
            Fail("The method clear_extension_cache did not work correctly ")
Esempio n. 2
0
def test_extension_cache():
    #set and get the attribute
    rand = _random.Random()
    value = rand.getrandbits(8)
    copyreg._extension_cache['cache1'] = value
    result = copyreg._extension_cache['cache1']
    Assert(result == value,
           "The get and set of the attribute failed")
    
    value = rand.getrandbits(16)
    copyreg._extension_cache['cache2'] = value
    result = copyreg._extension_cache['cache2']
    Assert(result == value,
           "The get and set of the attribute failed")

    #change the value of the attribue
    value2 = rand.getrandbits(4)
    copyreg._extension_cache['cache1'] = value2
    result = copyreg._extension_cache['cache1']
    Assert(result == value2,
           "The get and set of the attribute failed")
    
    if 'cache1' not in copyreg._extension_cache or  'cache2' not in copyreg._extension_cache:
        Fail("Set of the attribute failed")
        
    copyreg.clear_extension_cache()
    if  'cache1' in copyreg._extension_cache or 'cache2' in copyreg._extension_cache:
        Fail("The method clear_extension_cache did not work correctly ")
Esempio n. 3
0
    def trace_memory_clean_caches(self):
        """ Avoid polluting results with some builtin python caches """

        urllib.parse.clear_cache()
        re.purge()
        linecache.clearcache()
        copyreg.clear_extension_cache()

        if hasattr(fnmatch, "purge"):
            fnmatch.purge()  # pylint: disable=no-member
        elif hasattr(fnmatch, "_purge"):
            fnmatch._purge()

        if hasattr(encodings, "_cache") and len(encodings._cache) > 0:
            encodings._cache = {}

        context.log.handler.flush()
Esempio n. 4
0
File: job.py Progetto: tume/mrq
    def trace_memory_clean_caches(self):
        """ Avoid polluting results with some builtin python caches """

        urllib.parse.clear_cache()
        re.purge()
        linecache.clearcache()
        copyreg.clear_extension_cache()

        if hasattr(fnmatch, "purge"):
            fnmatch.purge()  # pylint: disable=no-member
        elif hasattr(fnmatch, "_purge"):
            fnmatch._purge()

        if hasattr(encodings, "_cache") and len(encodings._cache) > 0:
            encodings._cache = {}

        context.log.handler.flush()
Esempio n. 5
0
 def update_event(self, inp=-1):
     self.set_output_val(0, copyreg.clear_extension_cache())