Esempio n. 1
0
 def test_capturing_basic_api(self, method):
     capouter = StdCaptureFD()
     old = sys.stdout, sys.stderr, sys.stdin
     try:
         capman = CaptureManager(method)
         capman.start_global_capturing()
         capman.suspend_global_capture()
         outerr = capman.read_global_capture()
         assert outerr == ("", "")
         capman.suspend_global_capture()
         outerr = capman.read_global_capture()
         assert outerr == ("", "")
         print("hello")
         capman.suspend_global_capture()
         out, err = capman.read_global_capture()
         if method == "no":
             assert old == (sys.stdout, sys.stderr, sys.stdin)
         else:
             assert not out
         capman.resume_global_capture()
         print("hello")
         capman.suspend_global_capture()
         out, err = capman.read_global_capture()
         if method != "no":
             assert out == "hello\n"
         capman.stop_global_capturing()
     finally:
         capouter.stop_capturing()
Esempio n. 2
0
 def test_capturing_basic_api(self, method):
     capouter = StdCaptureFD()
     old = sys.stdout, sys.stderr, sys.stdin
     try:
         capman = CaptureManager(method)
         capman.start_global_capturing()
         capman.suspend_global_capture()
         outerr = capman.read_global_capture()
         assert outerr == ("", "")
         capman.suspend_global_capture()
         outerr = capman.read_global_capture()
         assert outerr == ("", "")
         print("hello")
         capman.suspend_global_capture()
         out, err = capman.read_global_capture()
         if method == "no":
             assert old == (sys.stdout, sys.stderr, sys.stdin)
         else:
             assert not out
         capman.resume_global_capture()
         print("hello")
         capman.suspend_global_capture()
         out, err = capman.read_global_capture()
         if method != "no":
             assert out == "hello\n"
         capman.stop_global_capturing()
     finally:
         capouter.stop_capturing()
Esempio n. 3
0
 def test_init_capturing(self):
     capouter = StdCaptureFD()
     try:
         capman = CaptureManager("fd")
         capman.start_global_capturing()
         pytest.raises(AssertionError, "capman.start_global_capturing()")
         capman.stop_global_capturing()
     finally:
         capouter.stop_capturing()
Esempio n. 4
0
 def test_init_capturing(self):
     capouter = StdCaptureFD()
     try:
         capman = CaptureManager("fd")
         capman.start_global_capturing()
         pytest.raises(AssertionError, capman.start_global_capturing)
         capman.stop_global_capturing()
     finally:
         capouter.stop_capturing()