[Django] #33256: Some schema tests don't clean up their tables

54 views
Skip to first unread message

Django

unread,
Nov 2, 2021, 7:21:10 PM11/2/21
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim | Owner: nobody
Graham |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Some test errors on a second consecutive run of `./tests/runtests.py
--settings=test_postgres --parallel=1 --keepdb schema` shows that some
tests leave behind their tables. Attached is an initial patch for a couple
of the cases.
{{{
======================================================================
ERROR: test_add_foreign_key_quoted_db_table (schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
psycopg2.errors.DuplicateTable: relation "table_author_double_quoted"
already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/tim/code/django/django/test/utils.py", line 437, in inner
return func(*args, **kwargs)
File "/home/tim/code/django/django/test/testcases.py", line 1305, in
skip_wrapper
return test_func(*args, **kwargs)
File "/home/tim/code/django/tests/schema/tests.py", line 3229, in
test_add_foreign_key_quoted_db_table
editor.create_model(Author)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
355, in create_model
self.execute(sql, params or None)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
151, in execute
cursor.execute(sql, params)
File "/home/tim/code/django/django/db/backends/utils.py", line 66, in
execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File "/home/tim/code/django/django/db/backends/utils.py", line 75, in
_execute_with_wrappers
return executor(sql, params, many, context)
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "table_author_double_quoted"
already exists


======================================================================
ERROR: test_add_foreign_object (schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
psycopg2.errors.DuplicateTable: relation "schema_bookforeignobj" already
exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/tim/code/django/tests/schema/tests.py", line 3238, in
test_add_foreign_object
editor.create_model(BookForeignObj)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
355, in create_model
self.execute(sql, params or None)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
151, in execute
cursor.execute(sql, params)
File "/home/tim/code/django/django/db/backends/utils.py", line 66, in
execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File "/home/tim/code/django/django/db/backends/utils.py", line 75, in
_execute_with_wrappers
return executor(sql, params, many, context)
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "schema_bookforeignobj" already
exists


======================================================================
ERROR: test_remove_db_index_doesnt_remove_custom_indexes
(schema.tests.SchemaTests)
Changing db_index to False doesn't remove indexes from Meta.indexes.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
psycopg2.errors.DuplicateTable: relation "schema_authorwithindexedname"
already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/tim/code/django/tests/schema/tests.py", line 2659, in
test_remove_db_index_doesnt_remove_custom_indexes
editor.create_model(AuthorWithIndexedName)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
355, in create_model
self.execute(sql, params or None)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
151, in execute
cursor.execute(sql, params)
File "/home/tim/code/django/django/db/backends/utils.py", line 66, in
execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File "/home/tim/code/django/django/db/backends/utils.py", line 75, in
_execute_with_wrappers
return executor(sql, params, many, context)
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "schema_authorwithindexedname"
already exists


======================================================================
ERROR: test_remove_field_unique_does_not_remove_meta_constraints
(schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
psycopg2.errors.DuplicateTable: relation "schema_authorwithuniquename"
already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/tim/code/django/django/test/testcases.py", line 1305, in
skip_wrapper
return test_func(*args, **kwargs)
File "/home/tim/code/django/tests/schema/tests.py", line 2057, in
test_remove_field_unique_does_not_remove_meta_constraints
editor.create_model(AuthorWithUniqueName)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
355, in create_model
self.execute(sql, params or None)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
151, in execute
cursor.execute(sql, params)
File "/home/tim/code/django/django/db/backends/utils.py", line 66, in
execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File "/home/tim/code/django/django/db/backends/utils.py", line 75, in
_execute_with_wrappers
return executor(sql, params, many, context)
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "schema_authorwithuniquename"
already exists


======================================================================
ERROR: test_remove_index_together_does_not_remove_meta_indexes
(schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
psycopg2.errors.DuplicateTable: relation
"schema_authorwithindexednameandbirthday" already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/tim/code/django/django/test/testcases.py", line 1305, in
skip_wrapper
return test_func(*args, **kwargs)
File "/home/tim/code/django/tests/schema/tests.py", line 2554, in
test_remove_index_together_does_not_remove_meta_indexes
editor.create_model(AuthorWithIndexedNameAndBirthday)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
355, in create_model
self.execute(sql, params or None)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
151, in execute
cursor.execute(sql, params)
File "/home/tim/code/django/django/db/backends/utils.py", line 66, in
execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File "/home/tim/code/django/django/db/backends/utils.py", line 75, in
_execute_with_wrappers
return executor(sql, params, many, context)
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation
"schema_authorwithindexednameandbirthday" already exists


======================================================================
ERROR: test_remove_unique_together_does_not_remove_meta_constraints
(schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
psycopg2.errors.DuplicateTable: relation
"schema_authorwithuniquenameandbirthday" already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/tim/code/django/django/test/testcases.py", line 1305, in
skip_wrapper
return test_func(*args, **kwargs)
File "/home/tim/code/django/tests/schema/tests.py", line 2176, in
test_remove_unique_together_does_not_remove_meta_constraints
editor.create_model(AuthorWithUniqueNameAndBirthday)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
355, in create_model
self.execute(sql, params or None)
File "/home/tim/code/django/django/db/backends/base/schema.py", line
151, in execute
cursor.execute(sql, params)
File "/home/tim/code/django/django/db/backends/utils.py", line 66, in
execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File "/home/tim/code/django/django/db/backends/utils.py", line 75, in
_execute_with_wrappers
return executor(sql, params, many, context)
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/tim/code/django/django/db/backends/utils.py", line 82, in
_execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation
"schema_authorwithuniquenameandbirthday" already exists


======================================================================
ERROR: test_unique_name_quoting (schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
psycopg2.errors.DuplicateTable: relation "unique-table" already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/tim/code/django/tests/schema/tests.py", line 1978, in
test_unique_name_quoting
editor.alter_db_table(TagUniqueRename, old_table_name, 'unique-table')
File "/home/tim/code/django/django/db/backends/base/schema.py", line
474, in alter_db_table
self.execute(self.sql_rename_table % {
File "/home/tim/code/django/django/db/backends/base/schema.py", line
151, in execute
cursor.execute(sql, params)
File "/home/tim/code/django/django/db/backends/utils.py", line 66, in
execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._execute)
File "/home/tim/code/django/django/db/backends/utils.py", line 75, in
_execute_with_wrappers
return executor(sql, params, many, context)
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/tim/code/django/django/db/backends/utils.py", line 84, in
_execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "unique-table" already exists
}}}

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

Django

unread,
Nov 2, 2021, 7:21:45 PM11/2/21
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* Attachment "33256-init.diff" added.

Django

unread,
Nov 3, 2021, 2:05:31 AM11/3/21
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


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

Django

unread,
Nov 4, 2021, 2:36:19 AM11/4/21
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: banani720
Type: | Status: assigned

Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* owner: nobody => banani720
* status: new => assigned


Comment:

[]

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

Django

unread,
Nov 4, 2021, 3:10:17 AM11/4/21
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: banani720
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by banani720):

If I have not done all of the cases yet, but just want to check in to see
if I am going about this the correct way, should I still submit a pr? I've
added a `try-finally` clauses to a couple of the test cases that are
mentioned in the error log. This is my first time contributing to an open-
source and the tutorial isn't quite clear how I should handle a situation
like this. Any guidance would be appreciated.

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

Django

unread,
Nov 4, 2021, 3:17:36 AM11/4/21
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: banani720
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mariusz Felisiak):

> If I have not done all of the cases yet, but just want to check in to
see if I am going about this the correct way, should I still submit a pr?

I don't think there is a need to submit PR at this stage. You should be
able to [https://docs.djangoproject.com/en/3.2/internals/contributing
/writing-code/unit-tests/ run tests locally] and check that all `schema`
tests work:
{{{
./runtests.py --settings=test_postgres --parallel=1 --keepdb schema
}}}
I'd submit PR when all test pass.

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

Django

unread,
Dec 29, 2021, 10:51:24 PM12/29/21
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: banani720
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Ayush Joshi):

Replying to [comment:4 Mariusz Felisiak]:


> > If I have not done all of the cases yet, but just want to check in to
see if I am going about this the correct way, should I still submit a pr?
>
> I don't think there is a need to submit PR at this stage. You should be
able to [https://docs.djangoproject.com/en/3.2/internals/contributing
/writing-code/unit-tests/ run tests locally] and check that all `schema`
tests work:
> {{{
> ./runtests.py --settings=test_postgres --parallel=1 --keepdb schema
> }}}
> I'd submit PR when all test pass.

When I run this command I don't know why but I'm getting the following
{{{ModuleNotFoundError}}}, could you please help?

{{{
Testing against Django installed in '/Python/django/django'


Traceback (most recent call last):

File "./runtests.py", line 657, in <module>
failures = django_tests(
File "./runtests.py", line 348, in django_tests
test_labels, state = setup_run_tests(verbosity, start_at, start_after,
test_labels)
File "./runtests.py", line 278, in setup_run_tests
test_modules, state = setup_collect_tests(start_at, start_after,
test_labels=test_labels)
File "./runtests.py", line 193, in setup_collect_tests
'INSTALLED_APPS': settings.INSTALLED_APPS,
File "/Python/django/django/conf/__init__.py", line 89, in __getattr__
self._setup(name)
File "/Python/django/django/conf/__init__.py", line 76, in _setup
self._wrapped = Settings(settings_module)
File "/Python/django/django/conf/__init__.py", line 184, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in
_find_and_load_unlocked
ModuleNotFoundError: No module named 'test_postgres'
}}}

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

Django

unread,
Dec 30, 2021, 12:13:35 AM12/30/21
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: banani720
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mariusz Felisiak):

Replying to [comment:5 Ayush Joshi]:


> When I run this command I don't know why but I'm getting the following
{{{ModuleNotFoundError}}}, could you please help?

`--settings` should be a path to your `settings` (see
[https://docs.djangoproject.com/en/4.0/internals/contributing/writing-code
/unit-tests/#using-another-settings-module docs]) not a test module. If
you're having trouble understanding how Django works, see
TicketClosingReasons/UseSupportChannels for ways to get help.

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

Django

unread,
Mar 9, 2022, 11:20:37 AM3/9/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: banani720
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mohammad Ali Mehdizadeh):

Can I work on this ticket please?

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

Django

unread,
Mar 13, 2022, 1:53:12 PM3/13/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: banani720
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mohammad Ali Mehdizadeh):

Replying to [ticket:33256 Tim Graham]:


I run the command but I can't produce errors, every thing works nice.

{{{
(django-venv) root@DESKTOP-N10114T:/mnt/d/mycode/django#


./tests/runtests.py --settings=test_postgres --parallel=1 --keepdb schema

Testing against Django installed in '/mnt/d/mycode/django/django'
Found 176 test(s).
Using existing test database for alias 'default'...
System check identified no issues (0 silenced).
.s................sss...s.ss.....s..ss.sss.s......ss.s......................s.............s.....................s..s....s...s.....................s.............s.....
.s...s...s
----------------------------------------------------------------------
Ran 176 tests in 11.057s

OK (skipped=28)
Preserving test database for alias 'default'...
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:8>

Django

unread,
Mar 13, 2022, 2:37:07 PM3/13/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: banani720
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Tim Graham):

Have you run the command a second time so that you're reusing an existing
database?

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:9>

Django

unread,
Mar 14, 2022, 4:08:44 AM3/14/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* owner: banani720 => Mohammad Ali Mehdizadeh


--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:10>

Django

unread,
Mar 15, 2022, 9:51:38 AM3/15/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mohammad Ali Mehdizadeh):

Replying to [comment:9 Tim Graham]:


> Have you run the command a second time so that you're reusing an
existing database?

No, I use a new instance of postgres and I check the databases and remove
''test_'' database each time.
But I can't produce errors.

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:11>

Django

unread,
Mar 15, 2022, 9:55:33 AM3/15/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mohammad Ali Mehdizadeh):

This is my test_postgres.py file:


{{{
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'USER': 'postgres_user',
'PASSWORD': 'postgres_password',
'HOST': 'postgres_host',
'PORT': 'postgres_port',
},
'other': {
'ENGINE': 'django.db.backends.postgresql',
'USER': 'postgres_user',
'PASSWORD': 'postgres_password',
'HOST': 'postgres_host',
'PORT': 'postgres_port',
},
}

SECRET_KEY = "django_tests_secret_key"

# Use a fast hasher to speed up tests.
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.MD5PasswordHasher",
]

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

USE_TZ = False
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:12>

Django

unread,
Mar 15, 2022, 9:58:08 AM3/15/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Tim Graham):

The errors happen on a second consecutive test run (and don't remove the
existing database between test runs).

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:13>

Django

unread,
Mar 16, 2022, 3:08:12 PM3/16/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mohammad Ali Mehdizadeh):

Thank you for guidance, I create the same error.

So have you any idea how to solve this issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:14>

Django

unread,
Mar 16, 2022, 5:00:03 PM3/16/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mohammad Ali Mehdizadeh):

Replying to [comment:13 Tim Graham]:

Thank you for guidance, I create the same error.
So have you any idea how to solve this issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:15>

Django

unread,
Mar 16, 2022, 5:29:26 PM3/16/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Tim Graham):

I attached an initial patch to this ticket. You should apply similar
techniques to other tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:16>

Django

unread,
Mar 18, 2022, 1:32:07 PM3/18/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Mohammad Ali Mehdizadeh):

Replying to [comment:16 Tim Graham]:
Do you have any idea, how to write a test for this scenario.

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:17>

Django

unread,
Mar 18, 2022, 1:50:31 PM3/18/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Tim Graham):

You only need to fix the existing errors. No additional tests are needed.

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:18>

Django

unread,
Mar 18, 2022, 5:32:33 PM3/18/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


Comment:

I create a PR [https://github.com/django/django/pull/15528]
feel free to feedback me

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:19>

Django

unread,
Mar 21, 2022, 3:01:35 AM3/21/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:20>

Django

unread,
Mar 21, 2022, 1:49:54 PM3/21/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| 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_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:21>

Django

unread,
Mar 22, 2022, 12:55:30 AM3/22/22
to django-...@googlegroups.com
#33256: Some schema tests don't clean up their tables
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Mohammad
Type: | Ali Mehdizadeh
Cleanup/optimization | Status: closed

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"4b66a5e61780416d8d99e61193f93dc3351caf2c" 4b66a5e6]:
{{{
#!CommitTicketReference repository=""
revision="4b66a5e61780416d8d99e61193f93dc3351caf2c"
Fixed #33256 -- Fixed schema test failures when using --keepdb.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33256#comment:22>

Reply all
Reply to author
Forward
0 new messages