Skip to content

TST: Fix bare pytest.raises in test_parsing.py #32102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 20, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pandas/tests/tslibs/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tests for Timestamp parsing, aimed at pandas/_libs/tslibs/parsing.pyx
"""
from datetime import datetime
import re

from dateutil.parser import parse
import numpy as np
Expand All @@ -24,7 +25,8 @@ def test_parse_time_string():

def test_parse_time_string_invalid_type():
# Raise on invalid input, don't just return it
with pytest.raises(TypeError):
msg = re.escape("Argument 'arg' has incorrect type (expected str, got tuple)")
with pytest.raises(TypeError, match=msg):
parse_time_string((4, 5))


Expand Down Expand Up @@ -217,7 +219,8 @@ def test_try_parse_dates():

def test_parse_time_string_check_instance_type_raise_exception():
# issue 20684
with pytest.raises(TypeError):
msg = re.escape("Argument 'arg' has incorrect type (expected str, got tuple)")
with pytest.raises(TypeError, match=msg):
parse_time_string((1, 2, 3))

result = parse_time_string("2019")
Expand Down