diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index 39d3ffdb286ab..2511063110f92 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -730,7 +730,7 @@ def test_omit_nuisance(df): grouped = df.groupby({'A': 0, 'C': 0, 'D': 1, 'E': 1}, axis=1) msg = (r'\("unsupported operand type\(s\) for \+: ' "'Timestamp' and 'float'\"" - r", u?'occurred at index 0'\)") + r", 'occurred at index 0'\)") with pytest.raises(TypeError, match=msg): grouped.agg(lambda x: x.sum(0, numeric_only=False)) diff --git a/pandas/tests/indexes/datetimes/test_construction.py b/pandas/tests/indexes/datetimes/test_construction.py index 0441a48255f22..56dfbfd485eb1 100644 --- a/pandas/tests/indexes/datetimes/test_construction.py +++ b/pandas/tests/indexes/datetimes/test_construction.py @@ -747,7 +747,7 @@ def test_from_freq_recreate_from_data(self, freq): def test_datetimeindex_constructor_misc(self): arr = ['1/1/2005', '1/2/2005', 'Jn 3, 2005', '2005-01-04'] - msg = r"(\(u?')?Unknown string format(:', 'Jn 3, 2005'\))?" + msg = r"(\(')?Unknown string format(:', 'Jn 3, 2005'\))?" with pytest.raises(ValueError, match=msg): DatetimeIndex(arr) diff --git a/pandas/tests/indexes/datetimes/test_tools.py b/pandas/tests/indexes/datetimes/test_tools.py index d0f551f55f5ad..d62d8d1276fec 100644 --- a/pandas/tests/indexes/datetimes/test_tools.py +++ b/pandas/tests/indexes/datetimes/test_tools.py @@ -1203,7 +1203,7 @@ def test_to_datetime_on_datetime64_series(self, cache): def test_to_datetime_with_space_in_series(self, cache): # GH 6428 s = Series(['10/18/2006', '10/18/2008', ' ']) - msg = r"(\(u?')?String does not contain a date(:', ' '\))?" + msg = r"(\(')?String does not contain a date(:', ' '\))?" with pytest.raises(ValueError, match=msg): to_datetime(s, errors='raise', cache=cache) result_coerce = to_datetime(s, errors='coerce', cache=cache) diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index b3beec95151fb..ff3a0900a848e 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -232,7 +232,7 @@ def test_loc_to_fail(self): with pytest.raises(KeyError, match=msg): s.loc[[-1, -2]] - msg = (r"\"None of \[Index\(\[u?'4'\], dtype='object'\)\] are" + msg = (r"\"None of \[Index\(\['4'\], dtype='object'\)\] are" r" in the \[index\]\"") with pytest.raises(KeyError, match=msg): s.loc[['4']] diff --git a/pandas/tests/indexing/test_partial.py b/pandas/tests/indexing/test_partial.py index c1d530cc890e5..172d18e29a45e 100644 --- a/pandas/tests/indexing/test_partial.py +++ b/pandas/tests/indexing/test_partial.py @@ -316,7 +316,7 @@ def test_series_partial_set_with_name(self): # raises as nothing in in the index msg = (r"\"None of \[Int64Index\(\[3, 3, 3\], dtype='int64'," - r" name=u?'idx'\)\] are in the \[index\]\"") + r" name='idx'\)\] are in the \[index\]\"") with pytest.raises(KeyError, match=msg): ser.loc[[3, 3, 3]] diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index d2d6e8d397013..d97a763fe2d0b 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -864,7 +864,7 @@ def test_misc_example(self): error_msg = """DataFrame\\.index are different DataFrame\\.index values are different \\(100\\.0 %\\) -\\[left\\]: Index\\(\\[u?'a', u?'b'\\], dtype='object'\\) +\\[left\\]: Index\\(\\['a', 'b'\\], dtype='object'\\) \\[right\\]: RangeIndex\\(start=0, stop=2, step=1\\)""" with pytest.raises(AssertionError, match=error_msg): assert_frame_equal(result, expected, check_index_type=False) diff --git a/pandas/tests/io/msgpack/test_pack.py b/pandas/tests/io/msgpack/test_pack.py index 5f15797d84939..ba9f1ae57741d 100644 --- a/pandas/tests/io/msgpack/test_pack.py +++ b/pandas/tests/io/msgpack/test_pack.py @@ -64,7 +64,7 @@ def testStrictUnicodeUnpack(self): unpackb(packb(b'abc\xeddef'), encoding='utf-8', use_list=1) def testStrictUnicodePack(self): - msg = (r"'ascii' codec can't encode character u*'\\xed' in position 3:" + msg = (r"'ascii' codec can't encode character '\\xed' in position 3:" r" ordinal not in range\(128\)") with pytest.raises(UnicodeEncodeError, match=msg): packb("abc\xeddef", encoding='ascii', unicode_errors='strict') diff --git a/pandas/tests/reshape/merge/test_merge.py b/pandas/tests/reshape/merge/test_merge.py index 5662377b98452..1c8f883436df0 100644 --- a/pandas/tests/reshape/merge/test_merge.py +++ b/pandas/tests/reshape/merge/test_merge.py @@ -654,7 +654,7 @@ def test_overlapping_columns_error_message(self): # #2649, #10639 df2.columns = ['key1', 'foo', 'foo'] - msg = (r"Data columns not unique: Index\(\[u?'foo', u?'foo'\]," + msg = (r"Data columns not unique: Index\(\['foo', 'foo'\]," r" dtype='object'\)") with pytest.raises(MergeError, match=msg): merge(df, df2) diff --git a/pandas/tests/util/test_assert_frame_equal.py b/pandas/tests/util/test_assert_frame_equal.py index 52d1286aa82a5..7aa8f1d527d39 100644 --- a/pandas/tests/util/test_assert_frame_equal.py +++ b/pandas/tests/util/test_assert_frame_equal.py @@ -140,8 +140,8 @@ def test_frame_equal_index_mismatch(): msg = """DataFrame\\.index are different DataFrame\\.index values are different \\(33\\.33333 %\\) -\\[left\\]: Index\\(\\[u?'a', u?'b', u?'c'\\], dtype='object'\\) -\\[right\\]: Index\\(\\[u?'a', u?'b', u?'d'\\], dtype='object'\\)""" +\\[left\\]: Index\\(\\['a', 'b', 'c'\\], dtype='object'\\) +\\[right\\]: Index\\(\\['a', 'b', 'd'\\], dtype='object'\\)""" df1 = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}, index=["a", "b", "c"]) @@ -156,8 +156,8 @@ def test_frame_equal_columns_mismatch(): msg = """DataFrame\\.columns are different DataFrame\\.columns values are different \\(50\\.0 %\\) -\\[left\\]: Index\\(\\[u?'A', u?'B'\\], dtype='object'\\) -\\[right\\]: Index\\(\\[u?'A', u?'b'\\], dtype='object'\\)""" +\\[left\\]: Index\\(\\['A', 'B'\\], dtype='object'\\) +\\[right\\]: Index\\(\\['A', 'b'\\], dtype='object'\\)""" df1 = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}, index=["a", "b", "c"]) diff --git a/pandas/tests/util/test_assert_index_equal.py b/pandas/tests/util/test_assert_index_equal.py index 4ba10777517c8..ec9cbd104d751 100644 --- a/pandas/tests/util/test_assert_index_equal.py +++ b/pandas/tests/util/test_assert_index_equal.py @@ -10,7 +10,7 @@ def test_index_equal_levels_mismatch(): Index levels are different \\[left\\]: 1, Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\) -\\[right\\]: 2, MultiIndex\\(levels=\\[\\[u?'A', u?'B'\\], \\[1, 2, 3, 4\\]\\], +\\[right\\]: 2, MultiIndex\\(levels=\\[\\['A', 'B'\\], \\[1, 2, 3, 4\\]\\], codes=\\[\\[0, 0, 1, 1\\], \\[0, 1, 2, 3\\]\\]\\)""" idx1 = Index([1, 2, 3]) @@ -151,8 +151,8 @@ def test_index_equal_names(name1, name2): if name1 == name2 or name1 is name2: assert_index_equal(idx1, idx2) else: - name1 = "u?'x'" if name1 == "x" else name1 - name2 = "u?'x'" if name2 == "x" else name2 + name1 = "'x'" if name1 == "x" else name1 + name2 = "'x'" if name2 == "x" else name2 msg = msg.format(name1=name1, name2=name2) with pytest.raises(AssertionError, match=msg): @@ -163,8 +163,8 @@ def test_index_equal_category_mismatch(check_categorical): msg = """Index are different Attribute "dtype" are different -\\[left\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b'\\], ordered=False\\) -\\[right\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b', u?'c'\\], \ +\\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\) +\\[right\\]: CategoricalDtype\\(categories=\\['a', 'b', 'c'\\], \ ordered=False\\)""" idx1 = Index(Categorical(["a", "b"])) diff --git a/pandas/tests/util/test_assert_series_equal.py b/pandas/tests/util/test_assert_series_equal.py index aae1cf65e10e2..61cabcf3f4aae 100644 --- a/pandas/tests/util/test_assert_series_equal.py +++ b/pandas/tests/util/test_assert_series_equal.py @@ -169,8 +169,8 @@ def test_series_equal_categorical_mismatch(check_categorical): msg = """Attributes are different Attribute "dtype" are different -\\[left\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b'\\], ordered=False\\) -\\[right\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b', u?'c'\\], \ +\\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\) +\\[right\\]: CategoricalDtype\\(categories=\\['a', 'b', 'c'\\], \ ordered=False\\)""" s1 = Series(Categorical(["a", "b"]))