Skip to content

Commit 2726a6a

Browse files
simonjayhawkinsjreback
authored andcommitted
CLN: Remove unicode u string prefix in regexes (#26433)
1 parent 84b11bc commit 2726a6a

File tree

11 files changed

+19
-19
lines changed

11 files changed

+19
-19
lines changed

pandas/tests/groupby/test_groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ def test_omit_nuisance(df):
730730
grouped = df.groupby({'A': 0, 'C': 0, 'D': 1, 'E': 1}, axis=1)
731731
msg = (r'\("unsupported operand type\(s\) for \+: '
732732
"'Timestamp' and 'float'\""
733-
r", u?'occurred at index 0'\)")
733+
r", 'occurred at index 0'\)")
734734
with pytest.raises(TypeError, match=msg):
735735
grouped.agg(lambda x: x.sum(0, numeric_only=False))
736736

pandas/tests/indexes/datetimes/test_construction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ def test_from_freq_recreate_from_data(self, freq):
747747

748748
def test_datetimeindex_constructor_misc(self):
749749
arr = ['1/1/2005', '1/2/2005', 'Jn 3, 2005', '2005-01-04']
750-
msg = r"(\(u?')?Unknown string format(:', 'Jn 3, 2005'\))?"
750+
msg = r"(\(')?Unknown string format(:', 'Jn 3, 2005'\))?"
751751
with pytest.raises(ValueError, match=msg):
752752
DatetimeIndex(arr)
753753

pandas/tests/indexes/datetimes/test_tools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ def test_to_datetime_on_datetime64_series(self, cache):
12031203
def test_to_datetime_with_space_in_series(self, cache):
12041204
# GH 6428
12051205
s = Series(['10/18/2006', '10/18/2008', ' '])
1206-
msg = r"(\(u?')?String does not contain a date(:', ' '\))?"
1206+
msg = r"(\(')?String does not contain a date(:', ' '\))?"
12071207
with pytest.raises(ValueError, match=msg):
12081208
to_datetime(s, errors='raise', cache=cache)
12091209
result_coerce = to_datetime(s, errors='coerce', cache=cache)

pandas/tests/indexing/test_loc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def test_loc_to_fail(self):
232232
with pytest.raises(KeyError, match=msg):
233233
s.loc[[-1, -2]]
234234

235-
msg = (r"\"None of \[Index\(\[u?'4'\], dtype='object'\)\] are"
235+
msg = (r"\"None of \[Index\(\['4'\], dtype='object'\)\] are"
236236
r" in the \[index\]\"")
237237
with pytest.raises(KeyError, match=msg):
238238
s.loc[['4']]

pandas/tests/indexing/test_partial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def test_series_partial_set_with_name(self):
316316

317317
# raises as nothing in in the index
318318
msg = (r"\"None of \[Int64Index\(\[3, 3, 3\], dtype='int64',"
319-
r" name=u?'idx'\)\] are in the \[index\]\"")
319+
r" name='idx'\)\] are in the \[index\]\"")
320320
with pytest.raises(KeyError, match=msg):
321321
ser.loc[[3, 3, 3]]
322322

pandas/tests/io/json/test_pandas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ def test_misc_example(self):
864864
error_msg = """DataFrame\\.index are different
865865
866866
DataFrame\\.index values are different \\(100\\.0 %\\)
867-
\\[left\\]: Index\\(\\[u?'a', u?'b'\\], dtype='object'\\)
867+
\\[left\\]: Index\\(\\['a', 'b'\\], dtype='object'\\)
868868
\\[right\\]: RangeIndex\\(start=0, stop=2, step=1\\)"""
869869
with pytest.raises(AssertionError, match=error_msg):
870870
assert_frame_equal(result, expected, check_index_type=False)

pandas/tests/io/msgpack/test_pack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def testStrictUnicodeUnpack(self):
6464
unpackb(packb(b'abc\xeddef'), encoding='utf-8', use_list=1)
6565

6666
def testStrictUnicodePack(self):
67-
msg = (r"'ascii' codec can't encode character u*'\\xed' in position 3:"
67+
msg = (r"'ascii' codec can't encode character '\\xed' in position 3:"
6868
r" ordinal not in range\(128\)")
6969
with pytest.raises(UnicodeEncodeError, match=msg):
7070
packb("abc\xeddef", encoding='ascii', unicode_errors='strict')

pandas/tests/reshape/merge/test_merge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def test_overlapping_columns_error_message(self):
652652

653653
# #2649, #10639
654654
df2.columns = ['key1', 'foo', 'foo']
655-
msg = (r"Data columns not unique: Index\(\[u?'foo', u?'foo'\],"
655+
msg = (r"Data columns not unique: Index\(\['foo', 'foo'\],"
656656
r" dtype='object'\)")
657657
with pytest.raises(MergeError, match=msg):
658658
merge(df, df2)

pandas/tests/util/test_assert_frame_equal.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def test_frame_equal_index_mismatch():
140140
msg = """DataFrame\\.index are different
141141
142142
DataFrame\\.index values are different \\(33\\.33333 %\\)
143-
\\[left\\]: Index\\(\\[u?'a', u?'b', u?'c'\\], dtype='object'\\)
144-
\\[right\\]: Index\\(\\[u?'a', u?'b', u?'d'\\], dtype='object'\\)"""
143+
\\[left\\]: Index\\(\\['a', 'b', 'c'\\], dtype='object'\\)
144+
\\[right\\]: Index\\(\\['a', 'b', 'd'\\], dtype='object'\\)"""
145145

146146
df1 = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]},
147147
index=["a", "b", "c"])
@@ -156,8 +156,8 @@ def test_frame_equal_columns_mismatch():
156156
msg = """DataFrame\\.columns are different
157157
158158
DataFrame\\.columns values are different \\(50\\.0 %\\)
159-
\\[left\\]: Index\\(\\[u?'A', u?'B'\\], dtype='object'\\)
160-
\\[right\\]: Index\\(\\[u?'A', u?'b'\\], dtype='object'\\)"""
159+
\\[left\\]: Index\\(\\['A', 'B'\\], dtype='object'\\)
160+
\\[right\\]: Index\\(\\['A', 'b'\\], dtype='object'\\)"""
161161

162162
df1 = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]},
163163
index=["a", "b", "c"])

pandas/tests/util/test_assert_index_equal.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_index_equal_levels_mismatch():
1010
1111
Index levels are different
1212
\\[left\\]: 1, Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\)
13-
\\[right\\]: 2, MultiIndex\\(levels=\\[\\[u?'A', u?'B'\\], \\[1, 2, 3, 4\\]\\],
13+
\\[right\\]: 2, MultiIndex\\(levels=\\[\\['A', 'B'\\], \\[1, 2, 3, 4\\]\\],
1414
codes=\\[\\[0, 0, 1, 1\\], \\[0, 1, 2, 3\\]\\]\\)"""
1515

1616
idx1 = Index([1, 2, 3])
@@ -151,8 +151,8 @@ def test_index_equal_names(name1, name2):
151151
if name1 == name2 or name1 is name2:
152152
assert_index_equal(idx1, idx2)
153153
else:
154-
name1 = "u?'x'" if name1 == "x" else name1
155-
name2 = "u?'x'" if name2 == "x" else name2
154+
name1 = "'x'" if name1 == "x" else name1
155+
name2 = "'x'" if name2 == "x" else name2
156156
msg = msg.format(name1=name1, name2=name2)
157157

158158
with pytest.raises(AssertionError, match=msg):
@@ -163,8 +163,8 @@ def test_index_equal_category_mismatch(check_categorical):
163163
msg = """Index are different
164164
165165
Attribute "dtype" are different
166-
\\[left\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b'\\], ordered=False\\)
167-
\\[right\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b', u?'c'\\], \
166+
\\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\)
167+
\\[right\\]: CategoricalDtype\\(categories=\\['a', 'b', 'c'\\], \
168168
ordered=False\\)"""
169169

170170
idx1 = Index(Categorical(["a", "b"]))

pandas/tests/util/test_assert_series_equal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ def test_series_equal_categorical_mismatch(check_categorical):
169169
msg = """Attributes are different
170170
171171
Attribute "dtype" are different
172-
\\[left\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b'\\], ordered=False\\)
173-
\\[right\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b', u?'c'\\], \
172+
\\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\)
173+
\\[right\\]: CategoricalDtype\\(categories=\\['a', 'b', 'c'\\], \
174174
ordered=False\\)"""
175175

176176
s1 = Series(Categorical(["a", "b"]))

0 commit comments

Comments
 (0)