Пример #1
0
def main(plan):
    # Now we are inside a function that will be passed a plan object, we
    # can add tests to this plan. Here we will add a unittest suite, made up
    # of a single TestCase defined above.
    plan.add(
        pyunit.PyUnit(name='My PyUnit',
                      description='PyUnit example testcase',
                      suite=unittest.makeSuite(MyTest)))
Пример #2
0
def main(plan):
    # Now we are inside a function that will be passed a plan object, we
    # can add tests to this plan. Here we will add a unittest suite, made up
    # of a single TestCase defined above.
    plan.add(
        pyunit.PyUnit(
            name="My PyUnit",
            description="PyUnit example testcase",
            testcases=[TestAlpha, TestBeta],
        ))
Пример #3
0
def test_passing_tests():
    """Test running a basic testsuite which should pass."""
    test_runner = pyunit.PyUnit(name="My PyUnit",
                                description="PyUnit example testcase",
                                suite=unittest.makeSuite(Passing),
                                **PYUNIT_DEFAULT_PARAMS)
    result = test_runner.run()
    report = result.report
    assert report.passed
    assert len(report.entries) == 1

    testcase_report = report.entries[0]
    assert testcase_report.passed
    assert len(testcase_report.entries) == 1

    log_entry = testcase_report.entries[0]
    assert log_entry["type"] == "Log"
    assert log_entry["message"] == "All PyUnit testcases passed"
Пример #4
0
def test_failing_tests():
    """Test running a basic testsuite which should fail."""
    test_runner = pyunit.PyUnit(name="My PyUnit",
                                description="PyUnit example testcase",
                                suite=unittest.makeSuite(Failing),
                                **PYUNIT_DEFAULT_PARAMS)
    result = test_runner.run()
    report = result.report
    assert not report.passed
    assert len(report.entries) == 1

    testcase_report = report.entries[0]
    assert not testcase_report.passed
    assert len(testcase_report.entries) == 2

    error_entry = testcase_report.entries[0]
    assert "RuntimeError: Boom" in error_entry["content"]
    assert "test_raises" in error_entry["description"]

    fail_entry = testcase_report.entries[1]
    assert "AssertionError: False is not true" in fail_entry["content"]
    assert "test_asserts_false" in fail_entry["description"]
Пример #5
0
def pyunit_runner_inst():
    """Return a PyUnit test runner instance."""
    return pyunit.PyUnit(name="My PyUnit",
                         description="PyUnit example test",
                         testcases=[Passing, Failing],
                         **PYUNIT_DEFAULT_PARAMS)