kopia lustrzana https://github.com/micropython/micropython-lib
test.support: Implement helpers required to run test_pep380.py.
rodzic
863538b44f
commit
21f8e09be8
|
@ -1,4 +1,8 @@
|
||||||
|
import sys
|
||||||
|
import io
|
||||||
import unittest
|
import unittest
|
||||||
|
import gc
|
||||||
|
import contextlib
|
||||||
|
|
||||||
|
|
||||||
TESTFN = '@test'
|
TESTFN = '@test'
|
||||||
|
@ -25,3 +29,31 @@ def skip_unless_symlink(test):
|
||||||
|
|
||||||
def create_empty_file(name):
|
def create_empty_file(name):
|
||||||
open(name, "w").close()
|
open(name, "w").close()
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def disable_gc():
|
||||||
|
have_gc = gc.isenabled()
|
||||||
|
gc.disable()
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
if have_gc:
|
||||||
|
gc.enable()
|
||||||
|
|
||||||
|
def gc_collect():
|
||||||
|
gc.collect()
|
||||||
|
gc.collect()
|
||||||
|
gc.collect()
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def captured_output(stream_name):
|
||||||
|
org = getattr(sys, stream_name)
|
||||||
|
buf = io.StringIO()
|
||||||
|
setattr(sys, stream_name, buf)
|
||||||
|
try:
|
||||||
|
yield buf
|
||||||
|
finally:
|
||||||
|
setattr(sys, stream_name, org)
|
||||||
|
|
||||||
|
def captured_stderr():
|
||||||
|
return captured_output("stderr")
|
||||||
|
|
Ładowanie…
Reference in New Issue