diff --git a/pandas/tests/io/parser/test_header.py b/pandas/tests/io/parser/test_header.py index 7dc106ef0c186..4cd110136d7b0 100644 --- a/pandas/tests/io/parser/test_header.py +++ b/pandas/tests/io/parser/test_header.py @@ -528,12 +528,11 @@ def test_multi_index_unnamed(all_parsers, index_col, columns): parser.read_csv(StringIO(data), header=header, index_col=index_col) else: result = parser.read_csv(StringIO(data), header=header, index_col=index_col) - template = "Unnamed: {i}_level_0" exp_columns = [] for i, col in enumerate(columns): if not col: # Unnamed. - col = template.format(i=i if index_col is None else i + 1) + col = f"Unnamed: {i if index_col is None else i + 1}_level_0" exp_columns.append(col) diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index fa04eabb71627..70713768c8d1e 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -1900,9 +1900,9 @@ class _TestMySQLAlchemy: @classmethod def connect(cls): - url = "mysql+{driver}://root@localhost/pandas_nosetest" return sqlalchemy.create_engine( - url.format(driver=cls.driver), connect_args=cls.connect_args + f"mysql+{cls.driver}://root@localhost/pandas_nosetest", + connect_args=cls.connect_args, ) @classmethod @@ -1969,8 +1969,9 @@ class _TestPostgreSQLAlchemy: @classmethod def connect(cls): - url = "postgresql+{driver}://postgres@localhost/pandas_nosetest" - return sqlalchemy.create_engine(url.format(driver=cls.driver)) + return sqlalchemy.create_engine( + f"postgresql+{cls.driver}://postgres@localhost/pandas_nosetest" + ) @classmethod def setup_driver(cls): diff --git a/pandas/tests/reductions/test_reductions.py b/pandas/tests/reductions/test_reductions.py index f6e0d2f0c1751..a112bc80b60b0 100644 --- a/pandas/tests/reductions/test_reductions.py +++ b/pandas/tests/reductions/test_reductions.py @@ -349,11 +349,10 @@ def test_invalid_td64_reductions(self, opname): msg = "|".join( [ - "reduction operation '{op}' not allowed for this dtype", - r"cannot perform {op} with type timedelta64\[ns\]", + f"reduction operation '{opname}' not allowed for this dtype", + rf"cannot perform {opname} with type timedelta64\[ns\]", ] ) - msg = msg.format(op=opname) with pytest.raises(TypeError, match=msg): getattr(td, opname)()