Esempio n. 1
0
def test_warnings_disabled():
    debug_ = Debug(warnings=False)
    with pytest.warns(None) as warnings:
        v1 = eval('debug_.format(1)')
        assert str(v1) == '<string>:1 <module>\n    1 (int)'
        v2 = debug_.format(1)
        assert 'test_warnings_disabled\n    1 (int)' in str(v2)
    assert len(warnings) == 0
Esempio n. 2
0
def test_small_call_frame():
    debug_ = Debug(warnings=False)
    v = debug_.format(
        1,
        2,
        3,
    )
    assert normalise_output(
        str(v)) == ('tests/test_main.py:<line no> test_small_call_frame\n'
                    '    1 (int)\n'
                    '    2 (int)\n'
                    '    3 (int)')
Esempio n. 3
0
def test_small_call_frame_warning():
    debug_ = Debug()
    v = debug_.format(
        1,
        2,
        3,
    )
    print('\n---\n{}\n---'.format(v))
    assert normalise_output(str(v)) == (
        'tests/test_main.py:<line no> test_small_call_frame_warning\n'
        '    1 (int)\n'
        '    2 (int)\n'
        '    3 (int)')
Esempio n. 4
0
def test_small_call_frame():
    debug_ = Debug(warnings=False, frame_context_length=2)
    v = debug_.format(
        1,
        2,
        3,
    )
    assert re.sub(r':\d{2,}', ':<line no>', str(v)) == (
        'tests/test_main.py:<line no> test_small_call_frame\n'
        '    1 (int)\n'
        '    2 (int)\n'
        '    3 (int)'
    )
Esempio n. 5
0
def test_small_call_frame_warning():
    debug_ = Debug()
    v = debug_.format(
        1,
        2,
        3,
    )
    print('\n---\n{}\n---'.format(v))
    assert re.sub(r':\d{2,}', ':<line no>', str(v)) == (
        'tests/test_main.py:<line no> test_small_call_frame_warning\n'
        '    1 (int)\n'
        '    2 (int)\n'
        '    3 (int)')
def test_small_call_frame_warning():
    debug_ = Debug(frame_context_length=2)
    v = debug_.format(
        1,
        2,
        3,
    )
    assert re.sub(r':\d{2,}', ':<line no>', str(v)) == (
        "tests/test_main.py:<line no> test_small_call_frame_warning "
        "(error passing code, found <class '_ast.Tuple'> not Call)\n"
        "    1 (int)\n"
        "    2 (int)\n"
        "    3 (int)")
Esempio n. 7
0
def test_small_call_frame_warning():
    debug_ = Debug(frame_context_length=2)
    v = debug_.format(
        1,
        2,
        3,
    )
    print('\n---\n{}\n---'.format(v))
    assert re.sub(r':\d{2,}', ':<line no>', str(v)) == (
        'tests/test_main.py:<line no> test_small_call_frame_warning '
        '(error parsing code, unable to find "format" function statement)\n'
        '    1 (int)\n'
        '    2 (int)\n'
        '    3 (int)')
def test_no_syntax_warning():
    # exceed the 4 extra lines which are normally checked
    debug_ = Debug(warnings=False)

    def func():
        return debug_.format(abs(abs(abs(abs(abs(-1))))))

    v = func()
    assert '(error parsing code' not in str(v)
    assert 'func' in str(v)
def test_no_syntax_warning():
    # exceed the 4 extra lines which are normally checked
    debug_ = Debug(warnings=False)

    def func():
        return debug_.format(abs(abs(abs(abs(abs(-1))))))

    v = func()
    s = re.sub(r':\d{2,}', ':<line no>', str(v))
    assert s == ('tests/test_expr_render.py:<line no> func\n'
                 '    abs( abs( abs( abs( abs( -1 ) ) ) ) ): 1 (int)')
Esempio n. 10
0
def test_no_syntax_warning():
    # exceed the 4 extra lines which are normally checked
    debug_ = Debug(warnings=False)

    def func():
        return debug_.format(abs(abs(abs(abs(abs(-1))))))

    v = func()
    s = normalise_output(str(v))
    assert s == (
        'tests/test_expr_render.py:<line no> test_no_syntax_warning.<locals>.func\n'
        '    abs( abs( abs( abs( abs( -1 ) ) ) ) ): 1 (int)')
def test_no_syntax_warning():
    # exceed the 4 extra lines which are normally checked
    debug_ = Debug(warnings=False)
    v = debug_.format(abs(abs(abs(abs(-1)))))
    assert '(error passing code' not in str(v)
    assert 'test_no_syntax_warning' in str(v)