def test_reporter_result_passed(assertion): r = Reporter() rs1 = r.create_and_track_resultset() rs1.assertion_passed(assertion) rs2 = r.create_and_track_resultset() rs2.assertion_passed(assertion) assert r.passed()
def test_reporter_result_not_passed(assertion): r = Reporter() rs1 = r.create_and_track_resultset() rs1.assertion_failed(assertion, "foo") rs2 = r.create_and_track_resultset() rs2.assertion_passed(assertion) assert not r.passed()
def test_get_failures(): # given two assertions a1 = AssertionCall(1) a1.actual_value = 4 a2 = AssertionCall("foo") a2.actual_value = "foo" r = Reporter() assert 0 == len(r.failures) rs1 = r.create_and_track_resultset() rs1.assertion_failed(a1, "users created") rs1.assertion_passed(a2) assert not r.passed() failures = r.failed_assertions() assert 1 == len(failures) f1 = failures[0] assert "assertion failed, expected 1, but got 4" == str(f1)
def test_commander_run_one_for_one(spec): reporter = MagicMock(Reporter(), unsafe=True) reporter.create_and_track_resultset.return_value = MagicMock(ResultSet, unsafe=True) c = Commander(spec, Flags.BLOCKING_E2E) c.run(reporter) reporter.feature.assert_called_once_with("One event"), reporter.scenario.assert_any_call("Send words1 event") # at least once called reporter.simulate.assert_called() reporter.validate.assert_called() reporter.run_task.assert_called() reporter.print_failures.assert_called_once_with() reporter.passed.assert_called_once()
def reporter(): return Reporter().scenario("pytest example scenario")
def test_reporter_result_empty_fails(assertion): r = Reporter() assert not r.passed()
def test_a_group_result_empty_fails(assertion): r = Reporter() r.create_and_track_resultset() # did not call assertion_failed or assertion_failed assert not r.passed()
def test_a_group_result_failed(assertion): r = Reporter() rs = r.create_and_track_resultset() rs.assertion_passed(assertion) rs.assertion_failed(assertion, "body field") assert not r.passed()
def test_a_group_result_passed(assertion): r = Reporter() rs = r.create_and_track_resultset() rs.assertion_passed(assertion) assert r.passed()
def reporter(): return Reporter().create_and_track_resultset()