Skip to content

Commit 1ad013e

Browse files
hramezanibluetech
authored andcommitted
Update code to Python3.6 style by applying pyupgrade.
1 parent d612811 commit 1ad013e

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
master_doc = 'index'
2727

2828
# General information about the project.
29-
project = u'pytest-django'
30-
copyright = u'%d, Andreas Pelme and contributors' % datetime.date.today().year
29+
project = 'pytest-django'
30+
copyright = '%d, Andreas Pelme and contributors' % datetime.date.today().year
3131

3232
exclude_patterns = ['_build']
3333

pytest_django/fixtures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def _set_suffix_to_test_databases(suffix: str) -> None:
293293
continue
294294

295295
db_settings.setdefault("TEST", {})
296-
db_settings["TEST"]["NAME"] = "{}_{}".format(test_name, suffix)
296+
db_settings["TEST"]["NAME"] = f"{test_name}_{suffix}"
297297

298298

299299
# ############### User visible fixtures ################
@@ -595,11 +595,11 @@ def _assert_num_queries(
595595
num,
596596
"" if exact else "or less ",
597597
"but {} done".format(
598-
num_performed == 1 and "1 was" or "{} were".format(num_performed)
598+
num_performed == 1 and "1 was" or f"{num_performed} were"
599599
),
600600
)
601601
if info:
602-
msg += "\n{}".format(info)
602+
msg += f"\n{info}"
603603
if verbose:
604604
sqls = (q["sql"] for q in context.captured_queries)
605605
msg += "\n\nQueries:\n========\n\n" + "\n\n".join(sqls)

pytest_django/live_server_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ def stop(self) -> None:
6969

7070
@property
7171
def url(self) -> str:
72-
return "http://{}:{}".format(self.thread.host, self.thread.port)
72+
return f"http://{self.thread.host}:{self.thread.port}"
7373

7474
def __str__(self) -> str:
7575
return self.url
7676

7777
def __add__(self, other) -> str:
78-
return "{}{}".format(self, other)
78+
return f"{self}{other}"
7979

8080
def __repr__(self) -> str:
8181
return "<LiveServer listening at %s>" % self.url

pytest_django/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ def _get_option_with_source(
331331
dc, dc_source = _get_option_with_source(options.dc, CONFIGURATION_ENV)
332332

333333
if ds:
334-
_report_header.append("settings: {} (from {})".format(ds, ds_source))
334+
_report_header.append(f"settings: {ds} (from {ds_source})")
335335
os.environ[SETTINGS_MODULE_ENV] = ds
336336

337337
if dc:
338-
_report_header.append("configuration: {} (from {})".format(dc, dc_source))
338+
_report_header.append(f"configuration: {dc} (from {dc_source})")
339339
os.environ[CONFIGURATION_ENV] = dc
340340

341341
# Install the django-configurations importer
@@ -619,7 +619,7 @@ def _get_origin():
619619
def __mod__(self, var: str) -> str:
620620
origin = self._get_origin()
621621
if origin:
622-
msg = "Undefined template variable '{}' in '{}'".format(var, origin)
622+
msg = f"Undefined template variable '{var}' in '{origin}'"
623623
else:
624624
msg = "Undefined template variable '%s'" % var
625625
if self.fail:

pytest_django_test/db_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
if TEST_DB_NAME is None:
2424
# No explicit test db name was given, construct a default one
25-
TEST_DB_NAME = "test_{}_inner".format(DB_NAME)
25+
TEST_DB_NAME = f"test_{DB_NAME}_inner"
2626
else:
2727
# An explicit test db name was given, is that as the base name
28-
TEST_DB_NAME = "{}_inner".format(TEST_DB_NAME)
28+
TEST_DB_NAME = f"{TEST_DB_NAME}_inner"
2929

3030
SECOND_DB_NAME = DB_NAME + '_second' if DB_NAME is not None else None
3131
SECOND_TEST_DB_NAME = TEST_DB_NAME + '_second' if DB_NAME is not None else None
@@ -93,7 +93,7 @@ def skip_if_sqlite_in_memory():
9393
def _get_db_name(db_suffix=None):
9494
name = TEST_DB_NAME
9595
if db_suffix:
96-
name = "{}_{}".format(name, db_suffix)
96+
name = f"{name}_{db_suffix}"
9797
return name
9898

9999

tests/test_fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def test_settings_before(self) -> None:
414414
from django.conf import settings
415415

416416
assert (
417-
"{}.{}".format(settings.__class__.__module__, settings.__class__.__name__)
417+
f"{settings.__class__.__module__}.{settings.__class__.__name__}"
418418
== "django.conf.Settings"
419419
)
420420
TestLiveServer._test_settings_before_run = True # type: ignore[attr-defined]
@@ -431,7 +431,7 @@ def test_settings_restored(self) -> None:
431431

432432
assert TestLiveServer._test_settings_before_run is True # type: ignore[attr-defined]
433433
assert (
434-
"{}.{}".format(settings.__class__.__module__, settings.__class__.__name__)
434+
f"{settings.__class__.__module__}.{settings.__class__.__name__}"
435435
== "django.conf.Settings"
436436
)
437437
assert settings.ALLOWED_HOSTS == ["testserver"]

0 commit comments

Comments
 (0)