test_ok1/testing/pytest/test_recording.py

43 lines
1.5 KiB
Python

import py,sys
class TestRecordingAccept:
def test_recording_and_back(self, testdir):
py.test.skip("implementation missing: recording")
p = testdir.makepyfile("""
import py
def test_fail():
assert x
def test_skip():
py.test.skip("hello")
def test_pass():
pass
""")
rdir = py.path.local("rdir")
result = self.runpytest(p, "--record=%s" %(rdir))
record = py.test.RecordDir(result)
testrun = record.getlastrun()
assert testrun.sys.platform == sys.platform
assert testrun.sys.version_info == sys.version_info
assert testrun.sys.executable == sys.executable
baseadress = ("test_one.py",)
failures = testrun.getfailures()
assert len(failures) == 1
failure = failures[0]
assert failure.testaddress == baseadress + ("test_fail",)
assert failure.location.find("test_one.py:3") != -1
assert failure.errmessage
assert failure.reprfailure # probably just a string for now
skipped = testrun.getskipped()
assert len(skipped) == 1
skip = skipped[0]
assert skip.testaddress == baseaddress + ("test_skip",)
assert skip.location == "test_one.py:7"
passed = testrun.getpassed()
assert len(passed) == 1
p = passed[0]
assert p.testaddress == baseaddress + ("test_skip",)