| 1 | | Replying to [ticket:33256 Tim Graham]: |
| 2 | | > 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. |
| 3 | | > {{{ |
| 4 | | > ====================================================================== |
| 5 | | > ERROR: test_add_foreign_key_quoted_db_table (schema.tests.SchemaTests) |
| 6 | | > ---------------------------------------------------------------------- |
| 7 | | > Traceback (most recent call last): |
| 8 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 9 | | > return self.cursor.execute(sql) |
| 10 | | > psycopg2.errors.DuplicateTable: relation "table_author_double_quoted" already exists |
| 11 | | > |
| 12 | | > |
| 13 | | > The above exception was the direct cause of the following exception: |
| 14 | | > |
| 15 | | > Traceback (most recent call last): |
| 16 | | > File "/home/tim/code/django/django/test/utils.py", line 437, in inner |
| 17 | | > return func(*args, **kwargs) |
| 18 | | > File "/home/tim/code/django/django/test/testcases.py", line 1305, in skip_wrapper |
| 19 | | > return test_func(*args, **kwargs) |
| 20 | | > File "/home/tim/code/django/tests/schema/tests.py", line 3229, in test_add_foreign_key_quoted_db_table |
| 21 | | > editor.create_model(Author) |
| 22 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 355, in create_model |
| 23 | | > self.execute(sql, params or None) |
| 24 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 151, in execute |
| 25 | | > cursor.execute(sql, params) |
| 26 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 66, in execute |
| 27 | | > return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) |
| 28 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers |
| 29 | | > return executor(sql, params, many, context) |
| 30 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 31 | | > return self.cursor.execute(sql, params) |
| 32 | | > File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__ |
| 33 | | > raise dj_exc_value.with_traceback(traceback) from exc_value |
| 34 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 35 | | > return self.cursor.execute(sql) |
| 36 | | > django.db.utils.ProgrammingError: relation "table_author_double_quoted" already exists |
| 37 | | > |
| 38 | | > |
| 39 | | > ====================================================================== |
| 40 | | > ERROR: test_add_foreign_object (schema.tests.SchemaTests) |
| 41 | | > ---------------------------------------------------------------------- |
| 42 | | > Traceback (most recent call last): |
| 43 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 44 | | > return self.cursor.execute(sql) |
| 45 | | > psycopg2.errors.DuplicateTable: relation "schema_bookforeignobj" already exists |
| 46 | | > |
| 47 | | > |
| 48 | | > The above exception was the direct cause of the following exception: |
| 49 | | > |
| 50 | | > Traceback (most recent call last): |
| 51 | | > File "/home/tim/code/django/tests/schema/tests.py", line 3238, in test_add_foreign_object |
| 52 | | > editor.create_model(BookForeignObj) |
| 53 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 355, in create_model |
| 54 | | > self.execute(sql, params or None) |
| 55 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 151, in execute |
| 56 | | > cursor.execute(sql, params) |
| 57 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 66, in execute |
| 58 | | > return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) |
| 59 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers |
| 60 | | > return executor(sql, params, many, context) |
| 61 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 62 | | > return self.cursor.execute(sql, params) |
| 63 | | > File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__ |
| 64 | | > raise dj_exc_value.with_traceback(traceback) from exc_value |
| 65 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 66 | | > return self.cursor.execute(sql) |
| 67 | | > django.db.utils.ProgrammingError: relation "schema_bookforeignobj" already exists |
| 68 | | > |
| 69 | | > |
| 70 | | > ====================================================================== |
| 71 | | > ERROR: test_remove_db_index_doesnt_remove_custom_indexes (schema.tests.SchemaTests) |
| 72 | | > Changing db_index to False doesn't remove indexes from Meta.indexes. |
| 73 | | > ---------------------------------------------------------------------- |
| 74 | | > Traceback (most recent call last): |
| 75 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 76 | | > return self.cursor.execute(sql) |
| 77 | | > psycopg2.errors.DuplicateTable: relation "schema_authorwithindexedname" already exists |
| 78 | | > |
| 79 | | > |
| 80 | | > The above exception was the direct cause of the following exception: |
| 81 | | > |
| 82 | | > Traceback (most recent call last): |
| 83 | | > File "/home/tim/code/django/tests/schema/tests.py", line 2659, in test_remove_db_index_doesnt_remove_custom_indexes |
| 84 | | > editor.create_model(AuthorWithIndexedName) |
| 85 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 355, in create_model |
| 86 | | > self.execute(sql, params or None) |
| 87 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 151, in execute |
| 88 | | > cursor.execute(sql, params) |
| 89 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 66, in execute |
| 90 | | > return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) |
| 91 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers |
| 92 | | > return executor(sql, params, many, context) |
| 93 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 94 | | > return self.cursor.execute(sql, params) |
| 95 | | > File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__ |
| 96 | | > raise dj_exc_value.with_traceback(traceback) from exc_value |
| 97 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 98 | | > return self.cursor.execute(sql) |
| 99 | | > django.db.utils.ProgrammingError: relation "schema_authorwithindexedname" already exists |
| 100 | | > |
| 101 | | > |
| 102 | | > ====================================================================== |
| 103 | | > ERROR: test_remove_field_unique_does_not_remove_meta_constraints (schema.tests.SchemaTests) |
| 104 | | > ---------------------------------------------------------------------- |
| 105 | | > Traceback (most recent call last): |
| 106 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 107 | | > return self.cursor.execute(sql) |
| 108 | | > psycopg2.errors.DuplicateTable: relation "schema_authorwithuniquename" already exists |
| 109 | | > |
| 110 | | > |
| 111 | | > The above exception was the direct cause of the following exception: |
| 112 | | > |
| 113 | | > Traceback (most recent call last): |
| 114 | | > File "/home/tim/code/django/django/test/testcases.py", line 1305, in skip_wrapper |
| 115 | | > return test_func(*args, **kwargs) |
| 116 | | > File "/home/tim/code/django/tests/schema/tests.py", line 2057, in test_remove_field_unique_does_not_remove_meta_constraints |
| 117 | | > editor.create_model(AuthorWithUniqueName) |
| 118 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 355, in create_model |
| 119 | | > self.execute(sql, params or None) |
| 120 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 151, in execute |
| 121 | | > cursor.execute(sql, params) |
| 122 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 66, in execute |
| 123 | | > return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) |
| 124 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers |
| 125 | | > return executor(sql, params, many, context) |
| 126 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 127 | | > return self.cursor.execute(sql, params) |
| 128 | | > File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__ |
| 129 | | > raise dj_exc_value.with_traceback(traceback) from exc_value |
| 130 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 131 | | > return self.cursor.execute(sql) |
| 132 | | > django.db.utils.ProgrammingError: relation "schema_authorwithuniquename" already exists |
| 133 | | > |
| 134 | | > |
| 135 | | > ====================================================================== |
| 136 | | > ERROR: test_remove_index_together_does_not_remove_meta_indexes (schema.tests.SchemaTests) |
| 137 | | > ---------------------------------------------------------------------- |
| 138 | | > Traceback (most recent call last): |
| 139 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 140 | | > return self.cursor.execute(sql) |
| 141 | | > psycopg2.errors.DuplicateTable: relation "schema_authorwithindexednameandbirthday" already exists |
| 142 | | > |
| 143 | | > |
| 144 | | > The above exception was the direct cause of the following exception: |
| 145 | | > |
| 146 | | > Traceback (most recent call last): |
| 147 | | > File "/home/tim/code/django/django/test/testcases.py", line 1305, in skip_wrapper |
| 148 | | > return test_func(*args, **kwargs) |
| 149 | | > File "/home/tim/code/django/tests/schema/tests.py", line 2554, in test_remove_index_together_does_not_remove_meta_indexes |
| 150 | | > editor.create_model(AuthorWithIndexedNameAndBirthday) |
| 151 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 355, in create_model |
| 152 | | > self.execute(sql, params or None) |
| 153 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 151, in execute |
| 154 | | > cursor.execute(sql, params) |
| 155 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 66, in execute |
| 156 | | > return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) |
| 157 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers |
| 158 | | > return executor(sql, params, many, context) |
| 159 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 160 | | > return self.cursor.execute(sql, params) |
| 161 | | > File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__ |
| 162 | | > raise dj_exc_value.with_traceback(traceback) from exc_value |
| 163 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 164 | | > return self.cursor.execute(sql) |
| 165 | | > django.db.utils.ProgrammingError: relation "schema_authorwithindexednameandbirthday" already exists |
| 166 | | > |
| 167 | | > |
| 168 | | > ====================================================================== |
| 169 | | > ERROR: test_remove_unique_together_does_not_remove_meta_constraints (schema.tests.SchemaTests) |
| 170 | | > ---------------------------------------------------------------------- |
| 171 | | > Traceback (most recent call last): |
| 172 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 173 | | > return self.cursor.execute(sql) |
| 174 | | > psycopg2.errors.DuplicateTable: relation "schema_authorwithuniquenameandbirthday" already exists |
| 175 | | > |
| 176 | | > |
| 177 | | > The above exception was the direct cause of the following exception: |
| 178 | | > |
| 179 | | > Traceback (most recent call last): |
| 180 | | > File "/home/tim/code/django/django/test/testcases.py", line 1305, in skip_wrapper |
| 181 | | > return test_func(*args, **kwargs) |
| 182 | | > File "/home/tim/code/django/tests/schema/tests.py", line 2176, in test_remove_unique_together_does_not_remove_meta_constraints |
| 183 | | > editor.create_model(AuthorWithUniqueNameAndBirthday) |
| 184 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 355, in create_model |
| 185 | | > self.execute(sql, params or None) |
| 186 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 151, in execute |
| 187 | | > cursor.execute(sql, params) |
| 188 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 66, in execute |
| 189 | | > return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) |
| 190 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers |
| 191 | | > return executor(sql, params, many, context) |
| 192 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 193 | | > return self.cursor.execute(sql, params) |
| 194 | | > File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__ |
| 195 | | > raise dj_exc_value.with_traceback(traceback) from exc_value |
| 196 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 82, in _execute |
| 197 | | > return self.cursor.execute(sql) |
| 198 | | > django.db.utils.ProgrammingError: relation "schema_authorwithuniquenameandbirthday" already exists |
| 199 | | > |
| 200 | | > |
| 201 | | > ====================================================================== |
| 202 | | > ERROR: test_unique_name_quoting (schema.tests.SchemaTests) |
| 203 | | > ---------------------------------------------------------------------- |
| 204 | | > Traceback (most recent call last): |
| 205 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 206 | | > return self.cursor.execute(sql, params) |
| 207 | | > psycopg2.errors.DuplicateTable: relation "unique-table" already exists |
| 208 | | > |
| 209 | | > |
| 210 | | > The above exception was the direct cause of the following exception: |
| 211 | | > |
| 212 | | > Traceback (most recent call last): |
| 213 | | > File "/home/tim/code/django/tests/schema/tests.py", line 1978, in test_unique_name_quoting |
| 214 | | > editor.alter_db_table(TagUniqueRename, old_table_name, 'unique-table') |
| 215 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 474, in alter_db_table |
| 216 | | > self.execute(self.sql_rename_table % { |
| 217 | | > File "/home/tim/code/django/django/db/backends/base/schema.py", line 151, in execute |
| 218 | | > cursor.execute(sql, params) |
| 219 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 66, in execute |
| 220 | | > return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) |
| 221 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers |
| 222 | | > return executor(sql, params, many, context) |
| 223 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 224 | | > return self.cursor.execute(sql, params) |
| 225 | | > File "/home/tim/code/django/django/db/utils.py", line 90, in __exit__ |
| 226 | | > raise dj_exc_value.with_traceback(traceback) from exc_value |
| 227 | | > File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute |
| 228 | | > return self.cursor.execute(sql, params) |
| 229 | | > django.db.utils.ProgrammingError: relation "unique-table" already exists |
| 230 | | > }}} |
| 231 | | |
| 232 | | |