From 76a0f8978b5953a5fa02a8675daf221f9c046161 Mon Sep 17 00:00:00 2001 From: Alvaro Santiesteban Date: Sat, 15 Feb 2020 19:50:17 +0000 Subject: [PATCH] Eighth batch of changes --- pandas/tests/test_downstream.py | 2 +- pandas/tests/test_multilevel.py | 6 +++--- pandas/tests/tools/test_numeric.py | 2 +- pandas/tests/tslibs/test_parse_iso8601.py | 2 +- pandas/tests/window/moments/test_moments_rolling.py | 10 +++------- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py index 02898988ca8aa..122ef1f47968e 100644 --- a/pandas/tests/test_downstream.py +++ b/pandas/tests/test_downstream.py @@ -19,7 +19,7 @@ def import_module(name): try: return importlib.import_module(name) except ModuleNotFoundError: # noqa - pytest.skip("skipping as {} not available".format(name)) + pytest.skip(f"skipping as {name} not available") @pytest.fixture diff --git a/pandas/tests/test_multilevel.py b/pandas/tests/test_multilevel.py index b377ca2869bd3..efaedfad1e093 100644 --- a/pandas/tests/test_multilevel.py +++ b/pandas/tests/test_multilevel.py @@ -896,10 +896,10 @@ def test_stack_unstack_unordered_multiindex(self): values = np.arange(5) data = np.vstack( [ - ["b{}".format(x) for x in values], # b0, b1, .. - ["a{}".format(x) for x in values], + [f"b{x}" for x in values], # b0, b1, .. + [f"a{x}" for x in values], # a0, a1, .. ] - ) # a0, a1, .. + ) df = pd.DataFrame(data.T, columns=["b", "a"]) df.columns.name = "first" second_level_dict = {"x": df} diff --git a/pandas/tests/tools/test_numeric.py b/pandas/tests/tools/test_numeric.py index 2fd39d5a7b703..19385e797467c 100644 --- a/pandas/tests/tools/test_numeric.py +++ b/pandas/tests/tools/test_numeric.py @@ -308,7 +308,7 @@ def test_really_large_in_arr_consistent(large_val, signed, multiple_elts, errors if errors in (None, "raise"): index = int(multiple_elts) - msg = "Integer out of range. at position {index}".format(index=index) + msg = f"Integer out of range. at position {index}" with pytest.raises(ValueError, match=msg): to_numeric(arr, **kwargs) diff --git a/pandas/tests/tslibs/test_parse_iso8601.py b/pandas/tests/tslibs/test_parse_iso8601.py index a58f227c20c7f..1c01e826d9794 100644 --- a/pandas/tests/tslibs/test_parse_iso8601.py +++ b/pandas/tests/tslibs/test_parse_iso8601.py @@ -51,7 +51,7 @@ def test_parsers_iso8601(date_str, exp): ], ) def test_parsers_iso8601_invalid(date_str): - msg = 'Error parsing datetime string "{s}"'.format(s=date_str) + msg = f'Error parsing datetime string "{date_str}"' with pytest.raises(ValueError, match=msg): tslib._test_parse_iso8601(date_str) diff --git a/pandas/tests/window/moments/test_moments_rolling.py b/pandas/tests/window/moments/test_moments_rolling.py index fd18d37ab13b6..f3a14971ef2e7 100644 --- a/pandas/tests/window/moments/test_moments_rolling.py +++ b/pandas/tests/window/moments/test_moments_rolling.py @@ -860,7 +860,7 @@ def get_result(obj, window, min_periods=None, center=False): tm.assert_series_equal(result, expected) # shifter index - s = ["x{x:d}".format(x=x) for x in range(12)] + s = [f"x{x:d}" for x in range(12)] if has_min_periods: minp = 10 @@ -1437,13 +1437,9 @@ def test_rolling_median_memory_error(self): def test_rolling_min_max_numeric_types(self): # GH12373 - types_test = [np.dtype("f{}".format(width)) for width in [4, 8]] + types_test = [np.dtype(f"f{width}") for width in [4, 8]] types_test.extend( - [ - np.dtype("{}{}".format(sign, width)) - for width in [1, 2, 4, 8] - for sign in "ui" - ] + [np.dtype(f"{sign}{width}") for width in [1, 2, 4, 8] for sign in "ui"] ) for data_type in types_test: # Just testing that these don't throw exceptions and that