Exemplo n.º 1
0
def test_ignore_partial_message():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning"):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 2
0
def test_assert_warns_partial_message():
    with all_warnings():
        warnings.simplefilter("error")
        with assert_warns(message="Warning"):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 3
0
def test_ignore_partial_message():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning"):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 4
0
def test_ignore_regex_message():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning .?!"):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 5
0
def test_assert_warns_regex_message():
    with all_warnings():
        warnings.simplefilter("error")
        with assert_warns(message="Warning .?!"):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 6
0
def test_assert_warns_regex_message():
    with all_warnings():
        warnings.simplefilter("error")
        with assert_warns(message="Warning .?!"):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 7
0
def test_assert_warns_partial_message():
    with all_warnings():
        warnings.simplefilter("error")
        with assert_warns(message="Warning"):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 8
0
def test_ignore_regex_message():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning .?!"):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 9
0
def test_ignore_type():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(category=UserWarning):
            warnsA()
            warnsC()
        with ignore_warning(category=DeprecationWarning):
            warnsB()
Exemplo n.º 10
0
def test_ignore_type():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(category=UserWarning):
            warnsA()
            warnsC()
        with ignore_warning(category=DeprecationWarning):
            warnsB()
Exemplo n.º 11
0
def test_assert_warns_type():
    with all_warnings():
        warnings.simplefilter("error")
        with assert_warns(category=UserWarning):
            warnsA()
            warnsC()
        with assert_warns(category=DeprecationWarning):
            warnsB()
Exemplo n.º 12
0
def test_assert_warns_type():
    with all_warnings():
        warnings.simplefilter("error")
        with assert_warns(category=UserWarning):
            warnsA()
            warnsC()
        with assert_warns(category=DeprecationWarning):
            warnsB()
Exemplo n.º 13
0
def test_ignore_full_message():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning A!"):
            warnsA()
        with ignore_warning(message="Warning B!"):
            warnsB()
        with ignore_warning(message="Warning C!"):
            warnsC()
Exemplo n.º 14
0
def test_ignore_full_message():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning A!"):
            warnsA()
        with ignore_warning(message="Warning B!"):
            warnsB()
        with ignore_warning(message="Warning C!"):
            warnsC()
Exemplo n.º 15
0
def test_ignore_type_fails():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(category=UserWarning):
            try:
                warnsB()
            except DeprecationWarning as e:
                nt.assert_equal(str(e), "Warning B!")
            else:
                raise ValueError("Expected warning to give error!")
Exemplo n.º 16
0
def test_assert_warns_type_fails():
    with all_warnings():
        warnings.simplefilter("error")
        try:
            with assert_warns(category=UserWarning):
                warnsB()
        except ValueError:
            pass
        else:
            raise ValueError("Expected warning to give error!")
Exemplo n.º 17
0
def test_assert_warns_message_fails():
    with all_warnings():
        warnings.simplefilter("error")
        try:
            with assert_warns(message="Warning [AB]!"):
                warnsC()
        except ValueError:
            pass
        else:
            raise AssertionError("ValueError expected!")
    with all_warnings():
        warnings.simplefilter("error")
        try:
            with assert_warns(message="Warning A! Too much"):
                warnsA()
        except ValueError:
            pass
        else:
            raise ValueError("ValueError expected!")
Exemplo n.º 18
0
def test_assert_warns_message_fails():
    with all_warnings():
        warnings.simplefilter("error")
        try:
            with assert_warns(message="Warning [AB]!"):
                warnsC()
        except ValueError:
            pass
        else:
            raise AssertionError("ValueError expected!")
    with all_warnings():
        warnings.simplefilter("error")
        try:
            with assert_warns(message="Warning A! Too much"):
                warnsA()
        except ValueError:
            pass
        else:
            raise ValueError("ValueError expected!")
Exemplo n.º 19
0
def test_assert_warns_type_fails():
    with all_warnings():
        warnings.simplefilter("error")
        try:
            with assert_warns(category=UserWarning):
                warnsB()
        except ValueError:
            pass
        else:
            raise ValueError("Expected warning to give error!")
Exemplo n.º 20
0
def test_ignore_type_fails():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(category=UserWarning):
            try:
                warnsB()
            except DeprecationWarning as e:
                assert str(e) == "Warning B!"
            else:
                raise ValueError("Expected warning to give error!")
Exemplo n.º 21
0
def test_ignore_message_fails():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning [AB]!"):
            warnsA()
            warnsB()
            try:
                warnsC()
            except UserWarning as e:
                assert str(e) == "Warning C!"
            else:
                raise ValueError("Expected warning to give error!")
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning A! Too much"):
            try:
                warnsA()
            except UserWarning as e:
                assert str(e) == "Warning A!"
            else:
                raise ValueError("Expected warning to give error!")
Exemplo n.º 22
0
def test_ignore_message_fails():
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning [AB]!"):
            warnsA()
            warnsB()
            try:
                warnsC()
            except UserWarning as e:
                nt.assert_equal(str(e), "Warning C!")
            else:
                raise ValueError("Expected warning to give error!")
    with all_warnings():
        warnings.simplefilter("error")
        with ignore_warning(message="Warning A! Too much"):
            try:
                warnsA()
            except UserWarning as e:
                nt.assert_equal(str(e), "Warning A!")
            else:
                raise ValueError("Expected warning to give error!")
Exemplo n.º 23
0
def test_assert_warns_full_message():
    with all_warnings():
        warnings.simplefilter("error")
        with assert_warns(message="Warning A!"):
            warnsA()
        with assert_warns(message="Warning B!"):
            warnsB()
        with assert_warns(message="Warning C!"):
            warnsC()

        with assert_warns(message=["Warning A!", "Warning B!", "Warning C!"]):
            warnsA()
            warnsB()
            warnsC()
Exemplo n.º 24
0
def test_assert_warns_full_message():
    with all_warnings():
        warnings.simplefilter("error")
        with assert_warns(message="Warning A!"):
            warnsA()
        with assert_warns(message="Warning B!"):
            warnsB()
        with assert_warns(message="Warning C!"):
            warnsC()

        with assert_warns(message=["Warning A!", "Warning B!", "Warning C!"]):
            warnsA()
            warnsB()
            warnsC()