Skip to content

Commit 4dc2b69

Browse files
simonjayhawkinsjreback
authored andcommitted
TST/STYLE: concatenate string literals post black reformatting (#27281)
1 parent acccdcc commit 4dc2b69

File tree

101 files changed

+227
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+227
-295
lines changed

pandas/tests/arithmetic/test_numeric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class TestMultiplicationDivision:
469469
pytest.param(
470470
pd.Index,
471471
marks=pytest.mark.xfail(
472-
reason="Index.__div__ always " "raises", raises=TypeError
472+
reason="Index.__div__ always raises", raises=TypeError
473473
),
474474
),
475475
pd.Series,

pandas/tests/arithmetic/test_period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ def test_add_iadd_timedeltalike_annual(self):
960960
def test_pi_add_sub_timedeltalike_freq_mismatch_annual(self, mismatched_freq):
961961
other = mismatched_freq
962962
rng = pd.period_range("2014", "2024", freq="A")
963-
msg = "Input has different freq(=.+)? " "from Period.*?\\(freq=A-DEC\\)"
963+
msg = "Input has different freq(=.+)? from Period.*?\\(freq=A-DEC\\)"
964964
with pytest.raises(IncompatibleFrequency, match=msg):
965965
rng + other
966966
with pytest.raises(IncompatibleFrequency, match=msg):

pandas/tests/arithmetic/test_timedelta64.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,19 @@ def _check(result, expected):
318318
_check(result, expected)
319319

320320
# tz mismatches
321-
msg = "Timestamp subtraction must have the same timezones or no" " timezones"
321+
msg = "Timestamp subtraction must have the same timezones or no timezones"
322322
with pytest.raises(TypeError, match=msg):
323323
dt_tz - ts
324324
msg = "can't subtract offset-naive and offset-aware datetimes"
325325
with pytest.raises(TypeError, match=msg):
326326
dt_tz - dt
327-
msg = "Timestamp subtraction must have the same timezones or no" " timezones"
327+
msg = "Timestamp subtraction must have the same timezones or no timezones"
328328
with pytest.raises(TypeError, match=msg):
329329
dt_tz - ts_tz2
330330
msg = "can't subtract offset-naive and offset-aware datetimes"
331331
with pytest.raises(TypeError, match=msg):
332332
dt - dt_tz
333-
msg = "Timestamp subtraction must have the same timezones or no" " timezones"
333+
msg = "Timestamp subtraction must have the same timezones or no timezones"
334334
with pytest.raises(TypeError, match=msg):
335335
ts - dt_tz
336336
with pytest.raises(TypeError, match=msg):
@@ -1771,7 +1771,7 @@ def test_td64arr_floordiv_int(self, box_with_array):
17711771
result = idx // 1
17721772
tm.assert_equal(result, idx)
17731773

1774-
pattern = "floor_divide cannot use operands|" "Cannot divide int by Timedelta*"
1774+
pattern = "floor_divide cannot use operands|Cannot divide int by Timedelta*"
17751775
with pytest.raises(TypeError, match=pattern):
17761776
1 // idx
17771777

pandas/tests/arrays/categorical/test_operators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def test_unordered_different_categories_raises(self):
313313
c1 = Categorical(["a", "b"], categories=["a", "b"], ordered=False)
314314
c2 = Categorical(["a", "c"], categories=["c", "a"], ordered=False)
315315

316-
with pytest.raises(TypeError, match=("Categoricals can " "only be compared")):
316+
with pytest.raises(TypeError, match=("Categoricals can only be compared")):
317317
c1 == c2
318318

319319
def test_compare_different_lengths(self):

pandas/tests/arrays/test_integer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_repr_dtype(dtype, expected):
8888

8989
def test_repr_array():
9090
result = repr(integer_array([1, None, 3]))
91-
expected = "<IntegerArray>\n" "[1, NaN, 3]\n" "Length: 3, dtype: Int64"
91+
expected = "<IntegerArray>\n[1, NaN, 3]\nLength: 3, dtype: Int64"
9292
assert result == expected
9393

9494

pandas/tests/arrays/test_period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_repr_small():
259259
arr = period_array(["2000", "2001"], freq="D")
260260
result = str(arr)
261261
expected = (
262-
"<PeriodArray>\n" "['2000-01-01', '2001-01-01']\n" "Length: 2, dtype: period[D]"
262+
"<PeriodArray>\n['2000-01-01', '2001-01-01']\nLength: 2, dtype: period[D]"
263263
)
264264
assert result == expected
265265

pandas/tests/computation/test_eval.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _eval_single_bin(lhs, cmp1, rhs, engine):
9292
return c(lhs, rhs)
9393
except ValueError as e:
9494
if str(e).startswith(
95-
"negative number cannot be " "raised to a fractional power"
95+
"negative number cannot be raised to a fractional power"
9696
):
9797
return np.nan
9898
raise
@@ -362,7 +362,7 @@ def get_expected_pow_result(self, lhs, rhs):
362362
expected = _eval_single_bin(lhs, "**", rhs, self.engine)
363363
except ValueError as e:
364364
if str(e).startswith(
365-
"negative number cannot be " "raised to a fractional power"
365+
"negative number cannot be raised to a fractional power"
366366
):
367367
if self.engine == "python":
368368
pytest.skip(str(e))
@@ -1944,7 +1944,7 @@ def test_empty_string_raises(engine, parser):
19441944

19451945

19461946
def test_more_than_one_expression_raises(engine, parser):
1947-
with pytest.raises(SyntaxError, match=("only a single expression " "is allowed")):
1947+
with pytest.raises(SyntaxError, match=("only a single expression is allowed")):
19481948
pd.eval("1 + 1; 2 + 2", engine=engine, parser=parser)
19491949

19501950

pandas/tests/extension/arrow/bool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def construct_from_string(cls, string):
3333
if string == cls.name:
3434
return cls()
3535
else:
36-
raise TypeError("Cannot construct a '{}' from " "'{}'".format(cls, string))
36+
raise TypeError("Cannot construct a '{}' from '{}'".format(cls, string))
3737

3838
@classmethod
3939
def construct_array_type(cls):

pandas/tests/extension/decimal/array.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def construct_from_string(cls, string):
4040
if string == cls.name:
4141
return cls()
4242
else:
43-
raise TypeError("Cannot construct a '{}' from " "'{}'".format(cls, string))
43+
raise TypeError("Cannot construct a '{}' from '{}'".format(cls, string))
4444

4545
@property
4646
def _is_numeric(self):
@@ -172,7 +172,7 @@ def _reduce(self, name, skipna=True, **kwargs):
172172
op = getattr(self.data, name)
173173
except AttributeError:
174174
raise NotImplementedError(
175-
"decimal does not support " "the {} operation".format(name)
175+
"decimal does not support the {} operation".format(name)
176176
)
177177
return op(axis=0)
178178

pandas/tests/extension/decimal/test_decimal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_series_repr(self, data):
207207
# TODO(extension)
208208
@pytest.mark.xfail(
209209
reason=(
210-
"raising AssertionError as this is not implemented, " "though easy enough to do"
210+
"raising AssertionError as this is not implemented, though easy enough to do"
211211
)
212212
)
213213
def test_series_constructor_coerce_data_to_extension_dtype_raises():

pandas/tests/extension/json/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def construct_from_string(cls, string):
4444
if string == cls.name:
4545
return cls()
4646
else:
47-
raise TypeError("Cannot construct a '{}' from " "'{}'".format(cls, string))
47+
raise TypeError("Cannot construct a '{}' from '{}'".format(cls, string))
4848

4949

5050
class JSONArray(ExtensionArray):

pandas/tests/frame/test_alter_axes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ def test_rename_axis_style_raises(self):
13041304
df = DataFrame({"A": [1, 2], "B": [1, 2]}, index=["0", "1"])
13051305

13061306
# Named target and axis
1307-
over_spec_msg = "Cannot specify both 'axis' and " "any of 'index' or 'columns'"
1307+
over_spec_msg = "Cannot specify both 'axis' and any of 'index' or 'columns'"
13081308
with pytest.raises(TypeError, match=over_spec_msg):
13091309
df.rename(index=str.lower, axis=1)
13101310

pandas/tests/frame/test_analytics.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,7 @@ def test_corr_cov_independent_index_column(self):
363363
def test_corr_invalid_method(self):
364364
# GH 22298
365365
df = pd.DataFrame(np.random.normal(size=(10, 2)))
366-
msg = (
367-
"method must be either 'pearson', " "'spearman', 'kendall', or a callable, "
368-
)
366+
msg = "method must be either 'pearson', 'spearman', 'kendall', or a callable, "
369367
with pytest.raises(ValueError, match=msg):
370368
df.corr(method="____")
371369

@@ -1441,7 +1439,7 @@ def test_mean_datetimelike(self):
14411439
tm.assert_series_equal(result, expected)
14421440

14431441
@pytest.mark.xfail(
1444-
reason="casts to object-dtype and then tries to " "add timestamps",
1442+
reason="casts to object-dtype and then tries to add timestamps",
14451443
raises=TypeError,
14461444
strict=True,
14471445
)
@@ -1643,7 +1641,7 @@ def test_idxmin(self, float_frame, int_frame):
16431641
expected = df.apply(Series.idxmin, axis=axis, skipna=skipna)
16441642
tm.assert_series_equal(result, expected)
16451643

1646-
msg = "No axis named 2 for object type" " <class 'pandas.core.frame.DataFrame'>"
1644+
msg = "No axis named 2 for object type <class 'pandas.core.frame.DataFrame'>"
16471645
with pytest.raises(ValueError, match=msg):
16481646
frame.idxmin(axis=2)
16491647

@@ -1658,7 +1656,7 @@ def test_idxmax(self, float_frame, int_frame):
16581656
expected = df.apply(Series.idxmax, axis=axis, skipna=skipna)
16591657
tm.assert_series_equal(result, expected)
16601658

1661-
msg = "No axis named 2 for object type" " <class 'pandas.core.frame.DataFrame'>"
1659+
msg = "No axis named 2 for object type <class 'pandas.core.frame.DataFrame'>"
16621660
with pytest.raises(ValueError, match=msg):
16631661
frame.idxmax(axis=2)
16641662

pandas/tests/frame/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_not_hashable(self):
149149
empty_frame = DataFrame()
150150

151151
df = self.klass([1])
152-
msg = "'(Sparse)?DataFrame' objects are mutable, thus they cannot be" " hashed"
152+
msg = "'(Sparse)?DataFrame' objects are mutable, thus they cannot be hashed"
153153
with pytest.raises(TypeError, match=msg):
154154
hash(df)
155155
with pytest.raises(TypeError, match=msg):

pandas/tests/frame/test_block_internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def f(dtype):
286286
data = list(itertools.repeat((datetime(2001, 1, 1), "aa", 20), 9))
287287
return DataFrame(data=data, columns=["A", "B", "C"], dtype=dtype)
288288

289-
msg = "compound dtypes are not implemented in the DataFrame" " constructor"
289+
msg = "compound dtypes are not implemented in the DataFrame constructor"
290290
with pytest.raises(NotImplementedError, match=msg):
291291
f([("A", "datetime64[h]"), ("B", "str"), ("C", "int32")])
292292

pandas/tests/frame/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def test_constructor_error_msgs(self):
474474
with pytest.raises(ValueError, match=msg):
475475
DataFrame((range(10), range(10, 20)), columns=("ones", "twos"))
476476

477-
msg = "If using all scalar " "values, you must pass " "an index"
477+
msg = "If using all scalar values, you must pass an index"
478478
with pytest.raises(ValueError, match=msg):
479479
DataFrame({"a": False, "b": True})
480480

pandas/tests/frame/test_dtypes.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,7 @@ def test_astype_dict_like(self, dtype_class):
686686
# in the keys of the dtype dict
687687
dt4 = dtype_class({"b": str, 2: str})
688688
dt5 = dtype_class({"e": str})
689-
msg = (
690-
"Only a column name can be used for the key in a dtype mappings" " argument"
691-
)
689+
msg = "Only a column name can be used for the key in a dtype mappings argument"
692690
with pytest.raises(KeyError, match=msg):
693691
df.astype(dt4)
694692
with pytest.raises(KeyError, match=msg):
@@ -1194,11 +1192,11 @@ def test_astype_str(self, timezone_frame):
11941192
with option_context("display.max_columns", 20):
11951193
result = str(timezone_frame)
11961194
assert (
1197-
"0 2013-01-01 2013-01-01 00:00:00-05:00 " "2013-01-01 00:00:00+01:00"
1195+
"0 2013-01-01 2013-01-01 00:00:00-05:00 2013-01-01 00:00:00+01:00"
11981196
) in result
11991197
assert (
1200-
"1 2013-01-02 " "NaT NaT"
1198+
"1 2013-01-02 NaT NaT"
12011199
) in result
12021200
assert (
1203-
"2 2013-01-03 2013-01-03 00:00:00-05:00 " "2013-01-03 00:00:00+01:00"
1201+
"2 2013-01-03 2013-01-03 00:00:00-05:00 2013-01-03 00:00:00+01:00"
12041202
) in result

pandas/tests/frame/test_missing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_dropna(self):
126126
assert_frame_equal(dropped, expected)
127127

128128
# bad input
129-
msg = "No axis named 3 for object type" " <class 'pandas.core.frame.DataFrame'>"
129+
msg = "No axis named 3 for object type <class 'pandas.core.frame.DataFrame'>"
130130
with pytest.raises(ValueError, match=msg):
131131
df.dropna(axis=3)
132132

@@ -362,7 +362,7 @@ def test_na_actions_categorical(self):
362362
res = df.fillna(value={"cats": 3, "vals": "b"})
363363
tm.assert_frame_equal(res, df_exp_fill)
364364

365-
with pytest.raises(ValueError, match=("fill value must " "be in categories")):
365+
with pytest.raises(ValueError, match=("fill value must be in categories")):
366366
df.fillna(value={"cats": 4, "vals": "c"})
367367

368368
res = df.fillna(method="pad")

pandas/tests/frame/test_quantile.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ def test_quantile_axis_parameter(self):
9090
result = df.quantile(0.5, axis="columns")
9191
assert_series_equal(result, expected)
9292

93-
msg = (
94-
"No axis named -1 for object type" " <class 'pandas.core.frame.DataFrame'>"
95-
)
93+
msg = "No axis named -1 for object type <class 'pandas.core.frame.DataFrame'>"
9694
with pytest.raises(ValueError, match=msg):
9795
df.quantile(0.1, axis=-1)
9896
msg = (

pandas/tests/frame/test_sorting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_sort_values(self):
5555
sorted_df = frame.sort_values(by=["B", "A"], ascending=[True, False])
5656
assert_frame_equal(sorted_df, expected)
5757

58-
msg = "No axis named 2 for object type" " <class 'pandas.core.frame.DataFrame'>"
58+
msg = "No axis named 2 for object type <class 'pandas.core.frame.DataFrame'>"
5959
with pytest.raises(ValueError, match=msg):
6060
frame.sort_values(by=["A", "B"], axis=2, inplace=True)
6161

pandas/tests/frame/test_timeseries.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ def test_frame_to_period(self):
901901
pts = df.to_period("M", axis=1)
902902
tm.assert_index_equal(pts.columns, exp.columns.asfreq("M"))
903903

904-
msg = "No axis named 2 for object type" " <class 'pandas.core.frame.DataFrame'>"
904+
msg = "No axis named 2 for object type <class 'pandas.core.frame.DataFrame'>"
905905
with pytest.raises(ValueError, match=msg):
906906
df.to_period(axis=2)
907907

pandas/tests/generic/test_generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,10 @@ def test_squeeze(self):
724724
tm.assert_series_equal(df.squeeze(axis=1), df.iloc[:, 0])
725725
tm.assert_series_equal(df.squeeze(axis="columns"), df.iloc[:, 0])
726726
assert df.squeeze() == df.iloc[0, 0]
727-
msg = "No axis named 2 for object type <class" " 'pandas.core.frame.DataFrame'>"
727+
msg = "No axis named 2 for object type <class 'pandas.core.frame.DataFrame'>"
728728
with pytest.raises(ValueError, match=msg):
729729
df.squeeze(axis=2)
730-
msg = "No axis named x for object type <class" " 'pandas.core.frame.DataFrame'>"
730+
msg = "No axis named x for object type <class 'pandas.core.frame.DataFrame'>"
731731
with pytest.raises(ValueError, match=msg):
732732
df.squeeze(axis="x")
733733

pandas/tests/groupby/test_function.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_builtins_apply(keys, f):
9292
result = df.groupby(keys).apply(f)
9393
ngroups = len(df.drop_duplicates(subset=keys))
9494

95-
assert_msg = "invalid frame shape: {} " "(expected ({}, 3))".format(
95+
assert_msg = "invalid frame shape: {} (expected ({}, 3))".format(
9696
result.shape, ngroups
9797
)
9898
assert result.shape == (ngroups, 3), assert_msg
@@ -1220,7 +1220,7 @@ def test_size_groupby_all_null():
12201220
def test_quantile(interpolation, a_vals, b_vals, q):
12211221
if interpolation == "nearest" and q == 0.5 and b_vals == [4, 3, 2, 1]:
12221222
pytest.skip(
1223-
"Unclear numpy expectation for nearest result with " "equidistant data"
1223+
"Unclear numpy expectation for nearest result with equidistant data"
12241224
)
12251225

12261226
a_expected = pd.Series(a_vals).quantile(q, interpolation=interpolation)
@@ -1243,9 +1243,7 @@ def test_quantile_raises():
12431243
[["foo", "a"], ["foo", "b"], ["foo", "c"]], columns=["key", "val"]
12441244
)
12451245

1246-
with pytest.raises(
1247-
TypeError, match="cannot be performed against " "'object' dtypes"
1248-
):
1246+
with pytest.raises(TypeError, match="cannot be performed against 'object' dtypes"):
12491247
df.groupby("key").quantile()
12501248

12511249

pandas/tests/groupby/test_grouping.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def test_groupby_grouper_f_sanity_checked(self):
378378
ts.groupby(lambda key: key[0:6])
379379

380380
def test_grouping_error_on_multidim_input(self, df):
381-
msg = "Grouper for '<class 'pandas.core.frame.DataFrame'>'" " not 1-dimensional"
381+
msg = "Grouper for '<class 'pandas.core.frame.DataFrame'>' not 1-dimensional"
382382
with pytest.raises(ValueError, match=msg):
383383
Grouping(df.index, df[["A", "A"]])
384384

pandas/tests/groupby/test_transform.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ def test_transform_with_non_scalar_group():
768768
@pytest.mark.parametrize("agg_func", ["count", "rank", "size"])
769769
def test_transform_numeric_ret(cols, exp, comp_func, agg_func):
770770
if agg_func == "size" and isinstance(cols, list):
771-
pytest.xfail("'size' transformation not supported with " "NDFrameGroupy")
771+
pytest.xfail("'size' transformation not supported with NDFrameGroupy")
772772

773773
# GH 19200
774774
df = pd.DataFrame(

pandas/tests/groupby/test_whitelist.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,7 @@ def test_groupby_blacklist(df_letters):
232232
blacklist.extend(to_methods)
233233

234234
# e.g., to_csv
235-
defined_but_not_allowed = (
236-
"(?:^Cannot.+{0!r}.+{1!r}.+try using the " "'apply' method$)"
237-
)
235+
defined_but_not_allowed = "(?:^Cannot.+{0!r}.+{1!r}.+try using the 'apply' method$)"
238236

239237
# e.g., query, eval
240238
not_defined = "(?:^{1!r} object has no attribute {0!r}$)"

pandas/tests/indexes/datetimes/test_construction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ def test_constructor_dtype(self):
663663
DatetimeIndex(idx, dtype="datetime64[ns]")
664664

665665
# this is effectively trying to convert tz's
666-
msg = "data is already tz-aware US/Eastern, unable to set specified" " tz: CET"
666+
msg = "data is already tz-aware US/Eastern, unable to set specified tz: CET"
667667
with pytest.raises(TypeError, match=msg):
668668
DatetimeIndex(idx, dtype="datetime64[ns, CET]")
669669
msg = "cannot supply both a tz and a dtype with a tz"

0 commit comments

Comments
 (0)