summaryrefslogtreecommitdiff
path: root/testing/test_capture.py
diff options
context:
space:
mode:
authorvictor <victor.maryama@typhoon-hil.com>2018-08-19 14:29:57 +0200
committervictor <victor.maryama@typhoon-hil.com>2018-08-19 14:29:57 +0200
commit9e382e8d29f0563925eedb3dc5139aaee72a1e1c (patch)
tree0326c0a092f824794ff9b6101f3561ff9ecc343d /testing/test_capture.py
parent2255892d65810cc4db2b82e2621ed313a0c47f7f (diff)
downloadpytest-9e382e8d29f0563925eedb3dc5139aaee72a1e1c.tar.gz
Fixed test.
Diffstat (limited to 'testing/test_capture.py')
-rw-r--r--testing/test_capture.py38
1 files changed, 24 insertions, 14 deletions
diff --git a/testing/test_capture.py b/testing/test_capture.py
index e47689c9c..b2185822a 100644
--- a/testing/test_capture.py
+++ b/testing/test_capture.py
@@ -1396,32 +1396,29 @@ def test_capture_with_live_logging(testdir):
def pytest_runtest_logreport(report):
if "test_global" in report.nodeid:
if report.when == "teardown":
- assert "fix setup" in report.caplog
- assert "something in test" in report.caplog
- assert "fix teardown" in report.caplog
-
- assert "fix setup" in report.capstdout
- assert "begin test" in report.capstdout
- assert "end test" in report.capstdout
- assert "fix teardown" in report.capstdout
+ with open("caplog", "w") as f:
+ f.write(report.caplog)
+ with open("capstdout", "w") as f:
+ f.write(report.capstdout)
""")
testdir.makepyfile(
"""
import logging
import sys
+ import pytest
logger = logging.getLogger(__name__)
@pytest.fixture
def fix1():
print("fix setup")
- logging("fix setup")
+ logging.info("fix setup")
yield
- logging("fix teardown")
+ logging.info("fix teardown")
print("fix teardown")
-
- def test_global():
+
+ def test_global(fix1):
print("begin test")
logging.info("something in test")
print("end test")
@@ -1434,9 +1431,7 @@ def test_capture_with_live_logging(testdir):
assert captured.err == "world\\n"
logging.info("something")
-
print("next")
-
logging.info("something")
captured = capsys.readouterr()
@@ -1445,3 +1440,18 @@ def test_capture_with_live_logging(testdir):
)
result = testdir.runpytest_subprocess("--log-cli-level=INFO")
assert result.ret == 0
+
+ with open("caplog", "r") as f:
+ caplog = f.read()
+
+ assert "fix setup" in caplog
+ assert "something in test" in caplog
+ assert "fix teardown" in caplog
+
+ with open("capstdout", "r") as f:
+ capstdout = f.read()
+
+ assert "fix setup" in capstdout
+ assert "begin test" in capstdout
+ assert "end test" in capstdout
+ assert "fix teardown" in capstdout