1# basic tests for gc module 2 3try: 4 import gc 5except ImportError: 6 print("SKIP") 7 raise SystemExit 8 9print(gc.isenabled()) 10gc.disable() 11print(gc.isenabled()) 12gc.enable() 13print(gc.isenabled()) 14 15gc.collect() 16 17if hasattr(gc, 'mem_free'): 18 # uPy has these extra functions 19 # just test they execute and return an int 20 assert type(gc.mem_free()) is int 21 assert type(gc.mem_alloc()) is int 22 23if hasattr(gc, 'threshold'): 24 # uPy has this extra function 25 # check execution and returns 26 assert(gc.threshold(1) is None) 27 assert(gc.threshold() == 0) 28 assert(gc.threshold(-1) is None) 29 assert(gc.threshold() == -1) 30 31 # Setting a low threshold should trigger collection at the list alloc 32 gc.threshold(1) 33 [[], []] 34 gc.threshold(-1) 35