def test_bad_machines_fail(machine): test_class = machine.TestCase try: with capture_out() as o: with raises(AssertionError): test_class().runTest() except Exception: print_unicode(o.getvalue()) raise v = o.getvalue() print_unicode(v) assert u'Step #1' in v assert u'Step #50' not in v
def test_bad_machines_fail(machine): test_class = machine.TestCase try: with capture_out() as o: with raises(AssertionError): test_class().runTest() except Exception: print_unicode(o.getvalue()) raise v = o.getvalue() print_unicode(v) steps = [l for l in v.splitlines() if 'Step ' in l or 'state.' in l] assert 1 <= len(steps) <= 50
def test_prints_note_in_failing_example(): @example(x=42) @example(x=43) @given(integers()) def test(x): note("x -> %d" % (x,)) assert x == 42 with capture_out() as out: with reporting.with_reporter(reporting.default): with pytest.raises(AssertionError): test() v = out.getvalue() print_unicode(v) assert "x -> 43" in v assert "x -> 42" not in v
def myfunc(self, data): print_unicode(data)
def test(x): print_unicode(u"x -> %d" % (x,))
def default(value): try: print_unicode(value) except UnicodeEncodeError: print_unicode(escape_unicode_characters(value))