Ejemplo n.º 1
0
def test_format_suite_errors():
    parser = Parser()
    suite_results = parser.parse([
        {
            u'status': u'failed',
            u'failedExpectations': [
                {"message": "ahhh", "stack": "stack1"},
                {"message": "oh no!", "stack": "stack2"}
            ]
        },
        {
            u'status': u'failed',
            u'failedExpectations': [
                {"message": "boom", "stack": "stack3"},
            ]
        }
    ])

    formatter = _create_console_formatter(suite_results=suite_results)
    assert formatter.format_suite_failure() == \
           "After All Failures:\n" \
           + "  ahhh\n" \
           + "  stack1\n" \
           + "  oh no!\n" \
           + "  stack2\n" \
           + "  boom\n" \
           + "  stack3\n"
Ejemplo n.º 2
0
def test_parser_returns_all_failed_expectations():
    parser = Parser()

    results = parser.parse([{
        u'failedExpectations': [
            {
                u'actual': u'Expectation1'
            },
            {
                u'actual': u'Expectation2'
            },
            {
                u'actual': u'Expectation3'
            },
            {
                u'actual': u'Expectation4'
            },
        ],
    }])

    assert len(results) == 1
    assert len(results[0].failed_expectations) == 4
    assert results[0].failed_expectations[0][u'actual'] == u'Expectation1'
    assert results[0].failed_expectations[1][u'actual'] == u'Expectation2'
    assert results[0].failed_expectations[2][u'actual'] == u'Expectation3'
    assert results[0].failed_expectations[3][u'actual'] == u'Expectation4'
Ejemplo n.º 3
0
def passing_results():
    parser = Parser()
    return parser.parse([
        {u'status': u'passed'},
        {u'status': u'passed'},
        {u'status': u'pending', u'fullName': u'Context is this test is pending'},
    ])
def test_format_suite_errors():
    parser = Parser()
    suite_results = parser.parse([
        {
            u'status': u'failed',
            u'failedExpectations': [
                {"message": "ahhh", "stack": "stack1"},
                {"message": "oh no!", "stack": "stack2"}
            ]
        },
        {
            u'status': u'failed',
            u'failedExpectations': [
                {"message": "boom", "stack": "stack3"},
            ]
        },
        {
            u'status': u'failed',
            u'failedExpectations': [
                {"message": "nope"},
            ]
        }
    ])

    formatter = _create_console_formatter(suite_results=suite_results)
    assert formatter.format_suite_failure() == \
           "Suite Failures:\n" \
           + "  ahhh\n" \
           + "  stack1\n" \
           + "  oh no!\n" \
           + "  stack2\n" \
           + "  boom\n" \
           + "  stack3\n" \
           + "  nope\n"
def passing_results():
    parser = Parser()
    return parser.parse([
        {u'status': u'passed'},
        {u'status': u'passed'},
        {u'status': u'pending', u'fullName': u'Context is this test is pending'},
    ])
def test_format_failures():
    parser = Parser()

    stack1 = u"""Error: Expected 'Batman' to equal 'PANTS'.
        at stack (http://localhost:8888/__jasmine__/jasmine.js:1110)
        at http://localhost:8888/__spec__/global_spec.js:3"""

    stack2 = u"""Error: Expected 'Batman' to equal 'Superman'.
        at stack (http://localhost:8888/__jasmine__/jasmine.js:1110)
        at http://localhost:8888/__spec__/global_spec.js:6"""

    stack3 = u"""Error: Expected 'Justice' to equal 'Served'.
        at stack (http://localhost:8888/__jasmine__/jasmine.js:1110)
        at http://localhost:8888/__spec__/global_spec.js:9"""

    results = parser.parse([
        {
            u'status': u'passed',
            u'fullName': u'Context is this test passes'
        },
        {
            u'status': u'failed',
            u'fullName': u'Context is this test fails',
            u'failedExpectations': [{
                u'stack': stack1,
                u'message': 'Message1'
            }]
        },
        {
            u'status':
            u'failed',
            u'fullName':
            u'Context is this test also fails',
            u'failedExpectations': [{
                u'stack': stack2,
                u'message': 'Message2'
            }, {
                u'stack': stack3,
                u'message': 'Message3'
            }]
        },
    ])

    formatter = _create_console_formatter(spec_results=results, colors=False)

    assert formatter.format_spec_failures() == \
           "Context is this test fails\n" + \
           "  Message1\n" + \
           "  Error: Expected 'Batman' to equal 'PANTS'.\n" + \
           "        at http://localhost:8888/__spec__/global_spec.js:3\n" + \
           "Context is this test also fails\n" + \
           "  Message2\n" + \
           "  Error: Expected 'Batman' to equal 'Superman'.\n" + \
           "        at http://localhost:8888/__spec__/global_spec.js:6\n" + \
           "  Message3\n" + \
           "  Error: Expected 'Justice' to equal 'Served'.\n" + \
           "        at http://localhost:8888/__spec__/global_spec.js:9\n"
def test_deprecation_warning():
    parser = Parser()

    specs = parser.parse(
        [
            {
                u'status': u'passed',
                u'fullName': u'Speccy',
                u'deprecationWarnings': [
                    {
                        u'message': u'spec deprecated',
                        u'stack': None
                    }
                ]
            }
        ]
    )

    suites = parser.parse(
        [
            {
                u'status': u'passed',
                u'fullName': u'Sweet',
                u'deprecationWarnings': [
                    {
                        u'message': u'suite deprecated',
                        u'stack': None
                    }
                ]
            }
        ]
    )

    formatter = _create_console_formatter(spec_results=specs, suite_results=suites, colors=False)
    assert formatter.format_deprecations() == \
            "Deprecations:\n" + \
            "Speccy\n" + \
            "  spec deprecated\n" + \
            "  \n" + \
            "Sweet\n" + \
            "  suite deprecated\n" +\
            "  \n"
def test_pending_with_message():
    parser = Parser()

    results = parser.parse([{
        u'status': u'pending',
        u'fullName': u'pending',
        u'pendingReason': 'the reason'
    }])

    formatter = _create_console_formatter(spec_results=results, colors=False)
    assert formatter.format_pending() == "pending\n  Reason: the reason\n"
Ejemplo n.º 9
0
def test_parser_should_return_a_correct_results_list():
    parser = Parser()

    results = parser.parse([
        {
            u'status': u'failed',
            u'fullName': u'Globals refer to the most holy.',
            u'failedExpectations': [
                {
                    u'actual': u'Batman',
                    u'matcherName': u'toEqual',
                    u'passed': False,
                    u'expected': u'PANTS',
                    u'message': u"Expected 'Batman' to equal 'PANTS'.",
                    u'stack': u"stack\n    stack\n    stack"
                }
            ],

            u'passedExpectations': [
                {
                    u'matcherName': u'toBeTruthy',
                    u'expected': [],
                    u'actual': True,
                    u'message': u'Passed.',
                    u'stack': u'',
                    u'passed': True
                }
            ],
            u'deprecationWarnings': [
                {
                    u'message': u'old and busted',
                    u'stack': u'snacky stack'
                }
            ],
            u'id': 0,
            u'description': u'refer to the most holy',
            u'pendingReason': u'pending reason'
        }
    ])

    assert len(results) == 1
    assert results[0].status == 'failed'
    assert results[0].full_name == 'Globals refer to the most holy.'
    assert len(results[0].failed_expectations) == 1
    assert results[0].failed_expectations[0]['stack'] == "stack\n    stack\n    stack"
    assert results[0].failed_expectations[0]['message'] == "Expected 'Batman' to equal 'PANTS'."
    assert results[0].pending_reason == u'pending reason'
    assert len(results[0].deprecation_warnings) == 1
    assert results[0].deprecation_warnings[0]['message'] == "old and busted"
    assert results[0].deprecation_warnings[0]['stack'] == "snacky stack"
Ejemplo n.º 10
0
def test_pending_with_message():
    parser = Parser()

    results = parser.parse(
        [
            {
                u'status': u'pending',
                u'fullName': u'pending',
                u'pendingReason': 'the reason'
            }
        ]
    )

    formatter = _create_console_formatter(spec_results=results, colors=False)
    assert formatter.format_pending() == "pending\n  Reason: the reason\n"
Ejemplo n.º 11
0
def test_parser_returns_all_failed_expectations():
    parser = Parser()

    results = parser.parse([
        {
            u'failedExpectations': [
                {u'actual': u'Expectation1'},
                {u'actual': u'Expectation2'},
                {u'actual': u'Expectation3'},
                {u'actual': u'Expectation4'},
            ],
        }
    ])

    assert len(results) == 1
    assert len(results[0].failed_expectations) == 4
    assert results[0].failed_expectations[0][u'actual'] == u'Expectation1'
    assert results[0].failed_expectations[1][u'actual'] == u'Expectation2'
    assert results[0].failed_expectations[2][u'actual'] == u'Expectation3'
    assert results[0].failed_expectations[3][u'actual'] == u'Expectation4'
Ejemplo n.º 12
0
def test_format_failures():
    parser = Parser()

    stack1 = u"""Error: Expected 'Batman' to equal 'PANTS'.
        at stack (http://localhost:8888/__jasmine__/jasmine.js:1110)
        at http://localhost:8888/__spec__/global_spec.js:3"""

    stack2 = u"""Error: Expected 'Batman' to equal 'Superman'.
        at stack (http://localhost:8888/__jasmine__/jasmine.js:1110)
        at http://localhost:8888/__spec__/global_spec.js:6"""

    stack3 = u"""Error: Expected 'Justice' to equal 'Served'.
        at stack (http://localhost:8888/__jasmine__/jasmine.js:1110)
        at http://localhost:8888/__spec__/global_spec.js:9"""

    results = parser.parse([
        {u'status': u'passed', u'fullName': u'Context is this test passes'},
        {u'status': u'failed', u'fullName': u'Context is this test fails',
         u'failedExpectations': [{u'stack': stack1, u'message': 'Message1'}]},
        {u'status': u'failed', u'fullName': u'Context is this test also fails',
         u'failedExpectations': [{u'stack': stack2, u'message': 'Message2'},
                                 {u'stack': stack3, u'message': 'Message3'}]},
    ])

    formatter = _create_console_formatter(spec_results=results, colors=False)

    assert formatter.format_spec_failures() == \
           "Context is this test fails\n" + \
           "  Message1\n" + \
           "  Error: Expected 'Batman' to equal 'PANTS'.\n" + \
           "        at http://localhost:8888/__spec__/global_spec.js:3\n" + \
           "Context is this test also fails\n" + \
           "  Message2\n" + \
           "  Error: Expected 'Batman' to equal 'Superman'.\n" + \
           "        at http://localhost:8888/__spec__/global_spec.js:6\n" + \
           "  Message3\n" + \
           "  Error: Expected 'Justice' to equal 'Served'.\n" + \
           "        at http://localhost:8888/__spec__/global_spec.js:9\n"
Ejemplo n.º 13
0
def test_parser_returns_an_empty_results_list_with_no_runnables():
    parser = Parser()
    results = parser.parse([])

    assert len(results) == 0
Ejemplo n.º 14
0
def test_parser_returns_an_empty_results_list_with_no_runnables():
    parser = Parser()
    results = parser.parse([])

    assert len(results) == 0