[Django] #32582: Extra dot between file name and extension on sqlite cloned test databases when using --parallel flag

25 views
Skip to first unread message

Django

unread,
Mar 22, 2021, 12:20:54 AM3/22/21
to django-...@googlegroups.com
#32582: Extra dot between file name and extension on sqlite cloned test databases
when using --parallel flag
-------------------------------------+-------------------------------------
Reporter: Christian | Owner: nobody
Abbott |
Type: Bug | Status: new
Component: Testing | Version: 3.1
framework | Keywords: sqlite test clone
Severity: Normal | database parallel
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
When asking Django to create on-disk (instead of in-memory) sqlite cloned
test databases by using the --parallel flag, the cloned file names are
created as, e.g., "test_db_1..sqlite3", "test_db_2..sqlite3", etc. (with
two dots instead of one).

If the specified test database name lacks any extension, e.g. just
'test_db', then the cloned file names have a trailing dot: "test_db_1.",
"test_db_2.", "test_db_3.", etc.

This is due to this line:

https://github.com/django/django/blob/main/django/db/backends/sqlite3/creation.py#L58

...in get_test_db_clone_settings() which constructs the file name using
the string:

{{{
'{}_{}.{}'.format(root, suffix, ext)
}}}

However, os.path.splitext() already includes the dot in the returned
extension ('ext'). Removing the dot from the format string seems the only
change needed to fix it:

{{{
'{}_{}{}'.format(root, suffix, ext)
}}}

From the github file history it looks like this quirk has been there since
the --parallel flag was first introduced (commit
0586c061f0b857e2259bea48e21ebb69a7878d13 in Sep 2015).


To reproduce the issue:

In settings.py, force on-disk instead of in-memory test databases by
specifying any test db name:

{{{
DATABASES = {
'default': {
ENGINE: 'django.db.backends.sqlite3',
NAME: 'db.sqlite3',
TEST: {
'NAME': test_db.sqlite3',
}
}
}
}}}

Create any model with migrations, and more than one TestCase class (to
ensure --parallel creates clones of the test database).

And on the command line, run tests with --parallel and --keepdb to see the
db files generated. This should be run on a multi-core processor.

{{{
manage.py test --parallel --keepdb
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32582>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 22, 2021, 2:46:17 AM3/22/21
to django-...@googlegroups.com
#32582: Extra dot in cloned test database file names on SQLite when using
--parallel.
-------------------------------------+-------------------------------------
Reporter: Christian Abbott | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: sqlite test clone | Triage Stage: Accepted
database parallel |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Good catch, would you like to prepare a patch? (tests are required)

--
Ticket URL: <https://code.djangoproject.com/ticket/32582#comment:1>

Django

unread,
Mar 22, 2021, 9:32:24 AM3/22/21
to django-...@googlegroups.com
#32582: Extra dot in cloned test database file names on SQLite when using
--parallel.
-------------------------------------+-------------------------------------
Reporter: Christian Abbott | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: sqlite test clone | Triage Stage: Accepted
database parallel |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Girish Sontakke):

Replying to [comment:1 Mariusz Felisiak]:


> Good catch, would you like to prepare a patch? (tests are required)

May I work on this patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/32582#comment:2>

Django

unread,
Mar 23, 2021, 12:51:23 AM3/23/21
to django-...@googlegroups.com
#32582: Extra dot in cloned test database file names on SQLite when using
--parallel.
-------------------------------------+-------------------------------------
Reporter: Christian Abbott | Owner: Girish
Type: | Sontakke
Cleanup/optimization | Status: assigned

Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: sqlite test clone | Triage Stage: Accepted
database parallel |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Girish Sontakke):

* owner: nobody => Girish Sontakke
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32582#comment:3>

Django

unread,
Mar 23, 2021, 1:16:37 AM3/23/21
to django-...@googlegroups.com
#32582: Extra dot in cloned test database file names on SQLite when using
--parallel.
-------------------------------------+-------------------------------------
Reporter: Christian Abbott | Owner: Girish
Type: | Sontakke
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: sqlite test clone | Triage Stage: Accepted
database parallel |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Girish Sontakke):

[https://github.com/django/django/pull/14169]

--
Ticket URL: <https://code.djangoproject.com/ticket/32582#comment:4>

Django

unread,
Mar 23, 2021, 2:04:40 AM3/23/21
to django-...@googlegroups.com
#32582: Extra dot in cloned test database file names on SQLite when using
--parallel.
-------------------------------------+-------------------------------------
Reporter: Christian Abbott | Owner: Girish
Type: | Sontakke
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: sqlite test clone | Triage Stage: Accepted
database parallel |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32582#comment:5>

Django

unread,
Mar 25, 2021, 1:29:06 AM3/25/21
to django-...@googlegroups.com
#32582: Extra dot in cloned test database file names on SQLite when using
--parallel.
-------------------------------------+-------------------------------------
Reporter: Christian Abbott | Owner: Girish
Type: | Sontakke
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: sqlite test clone | Triage Stage: Ready for
database parallel | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32582#comment:6>

Django

unread,
Mar 25, 2021, 1:37:32 AM3/25/21
to django-...@googlegroups.com
#32582: Extra dot in cloned test database file names on SQLite when using
--parallel.
-------------------------------------+-------------------------------------
Reporter: Christian Abbott | Owner: Girish
Type: | Sontakke
Cleanup/optimization | Status: closed

Component: Testing framework | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: sqlite test clone | Triage Stage: Ready for
database parallel | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"5388ff2a52ec87dae6638f5c1b85d1580f02a526" 5388ff2a]:
{{{
#!CommitTicketReference repository=""
revision="5388ff2a52ec87dae6638f5c1b85d1580f02a526"
Fixed #32582 -- Removed unnecessary dot in names of cloned test databases
on SQLite.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32582#comment:7>

Reply all
Reply to author
Forward
0 new messages