#35934: Migrations tests fail and leave behind files if 
tests/migrations/migrations
exists
-------------------------------------+-------------------------------------
     Reporter:  Jacob Walls          |                    Owner:  Jacob
         Type:                       |  Walls
  Cleanup/optimization               |                   Status:  assigned
    Component:  Migrations           |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

 * owner:  (none) => Jacob Walls
 * status:  new => assigned
 * summary:  Running the migrations tests leaves a dirty git status =>
     Migrations tests fail and leave behind files if
     tests/migrations/migrations exists

Comment:

 Sure thing, turns out I only encountered this because I had an extra
 directory left around from writing/debugging other tests, and merely
 deleting the files to get back to a clean git status didn't remove the
 directory causing the problem, leaving me a bit confused.

 To reproduce:
 {{{
 cd tests
 mkdir migrations/migrations
 ./runtests.py
 
migrations.test_commands.MakeMigrationsTests.test_makemigrations_empty_connections
 git status
 }}}

 Then, besides a dirty git status, that single test also fails...:
 {{{
 F
 ======================================================================
 FAIL: test_makemigrations_empty_connections
 
(migrations.test_commands.MakeMigrationsTests.test_makemigrations_empty_connections)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/Users/jwalls/django/tests/migrations/test_commands.py", line
 1551, in test_makemigrations_empty_connections
     self.assertIn("No changes detected", out.getvalue())
 AssertionError: 'No changes detected' not found in "\x1b[36;1mMigrations
 for 'migrations':\x1b[0m\n
 \x1b[1mmigrations/migrations/0001_initial.py\x1b[0m\n    + Create model
 ModelWithCustomBase\n    + Create model UnmigratedModel\n"

 ----------------------------------------------------------------------
 Ran 1 test in 0.102s

 FAILED (failures=1)
 }}}

 ...however, when running the whole migrations tests, several more tests
 fail with distinct outputs, further obscuring the source of the problem.

 A sanity check like might make the failures less mysterious? I won't be
 disappointed if it's a wontfix.
 {{{#!diff
 diff --git a/tests/migrations/test_commands.py
 b/tests/migrations/test_commands.py
 index 724c88a28f..3c7ce451f6 100644
 --- a/tests/migrations/test_commands.py
 +++ b/tests/migrations/test_commands.py
 @@ -1489,6 +1489,7 @@ class MakeMigrationsTests(MigrationTestBase):
      def setUp(self):
          super().setUp()
          self._old_models = apps.app_configs["migrations"].models.copy()
 +        self.assertFalse(os.path.exists("migrations"))

      def tearDown(self):
          apps.app_configs["migrations"].models = self._old_models
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35934#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/010701935b6f5cb0-392a7e87-d184-489d-8933-4da98f9e7f58-000000%40eu-central-1.amazonses.com.

Reply via email to