Skip to content

TST/STYLE: concatenate string literals post black reformatting #27281

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 1 commit into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pandas/tests/arithmetic/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class TestMultiplicationDivision:
pytest.param(
pd.Index,
marks=pytest.mark.xfail(
reason="Index.__div__ always " "raises", raises=TypeError
reason="Index.__div__ always raises", raises=TypeError
),
),
pd.Series,
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arithmetic/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def test_add_iadd_timedeltalike_annual(self):
def test_pi_add_sub_timedeltalike_freq_mismatch_annual(self, mismatched_freq):
other = mismatched_freq
rng = pd.period_range("2014", "2024", freq="A")
msg = "Input has different freq(=.+)? " "from Period.*?\\(freq=A-DEC\\)"
msg = "Input has different freq(=.+)? from Period.*?\\(freq=A-DEC\\)"
with pytest.raises(IncompatibleFrequency, match=msg):
rng + other
with pytest.raises(IncompatibleFrequency, match=msg):
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/arithmetic/test_timedelta64.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,19 @@ def _check(result, expected):
_check(result, expected)

# tz mismatches
msg = "Timestamp subtraction must have the same timezones or no" " timezones"
msg = "Timestamp subtraction must have the same timezones or no timezones"
with pytest.raises(TypeError, match=msg):
dt_tz - ts
msg = "can't subtract offset-naive and offset-aware datetimes"
with pytest.raises(TypeError, match=msg):
dt_tz - dt
msg = "Timestamp subtraction must have the same timezones or no" " timezones"
msg = "Timestamp subtraction must have the same timezones or no timezones"
with pytest.raises(TypeError, match=msg):
dt_tz - ts_tz2
msg = "can't subtract offset-naive and offset-aware datetimes"
with pytest.raises(TypeError, match=msg):
dt - dt_tz
msg = "Timestamp subtraction must have the same timezones or no" " timezones"
msg = "Timestamp subtraction must have the same timezones or no timezones"
with pytest.raises(TypeError, match=msg):
ts - dt_tz
with pytest.raises(TypeError, match=msg):
Expand Down Expand Up @@ -1771,7 +1771,7 @@ def test_td64arr_floordiv_int(self, box_with_array):
result = idx // 1
tm.assert_equal(result, idx)

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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/categorical/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def test_unordered_different_categories_raises(self):
c1 = Categorical(["a", "b"], categories=["a", "b"], ordered=False)
c2 = Categorical(["a", "c"], categories=["c", "a"], ordered=False)

with pytest.raises(TypeError, match=("Categoricals can " "only be compared")):
with pytest.raises(TypeError, match=("Categoricals can only be compared")):
c1 == c2

def test_compare_different_lengths(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_repr_dtype(dtype, expected):

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


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def test_repr_small():
arr = period_array(["2000", "2001"], freq="D")
result = str(arr)
expected = (
"<PeriodArray>\n" "['2000-01-01', '2001-01-01']\n" "Length: 2, dtype: period[D]"
"<PeriodArray>\n['2000-01-01', '2001-01-01']\nLength: 2, dtype: period[D]"
)
assert result == expected

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _eval_single_bin(lhs, cmp1, rhs, engine):
return c(lhs, rhs)
except ValueError as e:
if str(e).startswith(
"negative number cannot be " "raised to a fractional power"
"negative number cannot be raised to a fractional power"
):
return np.nan
raise
Expand Down Expand Up @@ -362,7 +362,7 @@ def get_expected_pow_result(self, lhs, rhs):
expected = _eval_single_bin(lhs, "**", rhs, self.engine)
except ValueError as e:
if str(e).startswith(
"negative number cannot be " "raised to a fractional power"
"negative number cannot be raised to a fractional power"
):
if self.engine == "python":
pytest.skip(str(e))
Expand Down Expand Up @@ -1944,7 +1944,7 @@ def test_empty_string_raises(engine, parser):


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


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/extension/arrow/bool.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def construct_from_string(cls, string):
if string == cls.name:
return cls()
else:
raise TypeError("Cannot construct a '{}' from " "'{}'".format(cls, string))
raise TypeError("Cannot construct a '{}' from '{}'".format(cls, string))

@classmethod
def construct_array_type(cls):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/extension/decimal/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def construct_from_string(cls, string):
if string == cls.name:
return cls()
else:
raise TypeError("Cannot construct a '{}' from " "'{}'".format(cls, string))
raise TypeError("Cannot construct a '{}' from '{}'".format(cls, string))

@property
def _is_numeric(self):
Expand Down Expand Up @@ -172,7 +172,7 @@ def _reduce(self, name, skipna=True, **kwargs):
op = getattr(self.data, name)
except AttributeError:
raise NotImplementedError(
"decimal does not support " "the {} operation".format(name)
"decimal does not support the {} operation".format(name)
)
return op(axis=0)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/extension/decimal/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def test_series_repr(self, data):
# TODO(extension)
@pytest.mark.xfail(
reason=(
"raising AssertionError as this is not implemented, " "though easy enough to do"
"raising AssertionError as this is not implemented, though easy enough to do"
)
)
def test_series_constructor_coerce_data_to_extension_dtype_raises():
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/extension/json/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def construct_from_string(cls, string):
if string == cls.name:
return cls()
else:
raise TypeError("Cannot construct a '{}' from " "'{}'".format(cls, string))
raise TypeError("Cannot construct a '{}' from '{}'".format(cls, string))


class JSONArray(ExtensionArray):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ def test_rename_axis_style_raises(self):
df = DataFrame({"A": [1, 2], "B": [1, 2]}, index=["0", "1"])

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

Expand Down
10 changes: 4 additions & 6 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,7 @@ def test_corr_cov_independent_index_column(self):
def test_corr_invalid_method(self):
# GH 22298
df = pd.DataFrame(np.random.normal(size=(10, 2)))
msg = (
"method must be either 'pearson', " "'spearman', 'kendall', or a callable, "
)
msg = "method must be either 'pearson', 'spearman', 'kendall', or a callable, "
with pytest.raises(ValueError, match=msg):
df.corr(method="____")

Expand Down Expand Up @@ -1441,7 +1439,7 @@ def test_mean_datetimelike(self):
tm.assert_series_equal(result, expected)

@pytest.mark.xfail(
reason="casts to object-dtype and then tries to " "add timestamps",
reason="casts to object-dtype and then tries to add timestamps",
raises=TypeError,
strict=True,
)
Expand Down Expand Up @@ -1643,7 +1641,7 @@ def test_idxmin(self, float_frame, int_frame):
expected = df.apply(Series.idxmin, axis=axis, skipna=skipna)
tm.assert_series_equal(result, expected)

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_not_hashable(self):
empty_frame = DataFrame()

df = self.klass([1])
msg = "'(Sparse)?DataFrame' objects are mutable, thus they cannot be" " hashed"
msg = "'(Sparse)?DataFrame' objects are mutable, thus they cannot be hashed"
with pytest.raises(TypeError, match=msg):
hash(df)
with pytest.raises(TypeError, match=msg):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_block_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def f(dtype):
data = list(itertools.repeat((datetime(2001, 1, 1), "aa", 20), 9))
return DataFrame(data=data, columns=["A", "B", "C"], dtype=dtype)

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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def test_constructor_error_msgs(self):
with pytest.raises(ValueError, match=msg):
DataFrame((range(10), range(10, 20)), columns=("ones", "twos"))

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

Expand Down
10 changes: 4 additions & 6 deletions pandas/tests/frame/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,7 @@ def test_astype_dict_like(self, dtype_class):
# in the keys of the dtype dict
dt4 = dtype_class({"b": str, 2: str})
dt5 = dtype_class({"e": str})
msg = (
"Only a column name can be used for the key in a dtype mappings" " argument"
)
msg = "Only a column name can be used for the key in a dtype mappings argument"
with pytest.raises(KeyError, match=msg):
df.astype(dt4)
with pytest.raises(KeyError, match=msg):
Expand Down Expand Up @@ -1194,11 +1192,11 @@ def test_astype_str(self, timezone_frame):
with option_context("display.max_columns", 20):
result = str(timezone_frame)
assert (
"0 2013-01-01 2013-01-01 00:00:00-05:00 " "2013-01-01 00:00:00+01:00"
"0 2013-01-01 2013-01-01 00:00:00-05:00 2013-01-01 00:00:00+01:00"
) in result
assert (
"1 2013-01-02 " "NaT NaT"
"1 2013-01-02 NaT NaT"
) in result
assert (
"2 2013-01-03 2013-01-03 00:00:00-05:00 " "2013-01-03 00:00:00+01:00"
"2 2013-01-03 2013-01-03 00:00:00-05:00 2013-01-03 00:00:00+01:00"
) in result
4 changes: 2 additions & 2 deletions pandas/tests/frame/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_dropna(self):
assert_frame_equal(dropped, expected)

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

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

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

res = df.fillna(method="pad")
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/frame/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ def test_quantile_axis_parameter(self):
result = df.quantile(0.5, axis="columns")
assert_series_equal(result, expected)

msg = (
"No axis named -1 for object type" " <class 'pandas.core.frame.DataFrame'>"
)
msg = "No axis named -1 for object type <class 'pandas.core.frame.DataFrame'>"
with pytest.raises(ValueError, match=msg):
df.quantile(0.1, axis=-1)
msg = (
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_sort_values(self):
sorted_df = frame.sort_values(by=["B", "A"], ascending=[True, False])
assert_frame_equal(sorted_df, expected)

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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ def test_frame_to_period(self):
pts = df.to_period("M", axis=1)
tm.assert_index_equal(pts.columns, exp.columns.asfreq("M"))

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

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/generic/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,10 @@ def test_squeeze(self):
tm.assert_series_equal(df.squeeze(axis=1), df.iloc[:, 0])
tm.assert_series_equal(df.squeeze(axis="columns"), df.iloc[:, 0])
assert df.squeeze() == df.iloc[0, 0]
msg = "No axis named 2 for object type <class" " 'pandas.core.frame.DataFrame'>"
msg = "No axis named 2 for object type <class 'pandas.core.frame.DataFrame'>"
with pytest.raises(ValueError, match=msg):
df.squeeze(axis=2)
msg = "No axis named x for object type <class" " 'pandas.core.frame.DataFrame'>"
msg = "No axis named x for object type <class 'pandas.core.frame.DataFrame'>"
with pytest.raises(ValueError, match=msg):
df.squeeze(axis="x")

Expand Down
8 changes: 3 additions & 5 deletions pandas/tests/groupby/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_builtins_apply(keys, f):
result = df.groupby(keys).apply(f)
ngroups = len(df.drop_duplicates(subset=keys))

assert_msg = "invalid frame shape: {} " "(expected ({}, 3))".format(
assert_msg = "invalid frame shape: {} (expected ({}, 3))".format(
result.shape, ngroups
)
assert result.shape == (ngroups, 3), assert_msg
Expand Down Expand Up @@ -1220,7 +1220,7 @@ def test_size_groupby_all_null():
def test_quantile(interpolation, a_vals, b_vals, q):
if interpolation == "nearest" and q == 0.5 and b_vals == [4, 3, 2, 1]:
pytest.skip(
"Unclear numpy expectation for nearest result with " "equidistant data"
"Unclear numpy expectation for nearest result with equidistant data"
)

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

with pytest.raises(
TypeError, match="cannot be performed against " "'object' dtypes"
):
with pytest.raises(TypeError, match="cannot be performed against 'object' dtypes"):
df.groupby("key").quantile()


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def test_groupby_grouper_f_sanity_checked(self):
ts.groupby(lambda key: key[0:6])

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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ def test_transform_with_non_scalar_group():
@pytest.mark.parametrize("agg_func", ["count", "rank", "size"])
def test_transform_numeric_ret(cols, exp, comp_func, agg_func):
if agg_func == "size" and isinstance(cols, list):
pytest.xfail("'size' transformation not supported with " "NDFrameGroupy")
pytest.xfail("'size' transformation not supported with NDFrameGroupy")

# GH 19200
df = pd.DataFrame(
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/groupby/test_whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ def test_groupby_blacklist(df_letters):
blacklist.extend(to_methods)

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

# e.g., query, eval
not_defined = "(?:^{1!r} object has no attribute {0!r}$)"
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def test_constructor_dtype(self):
DatetimeIndex(idx, dtype="datetime64[ns]")

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