Opened 10 years ago
Closed 10 years ago
#23850 closed Bug (fixed)
Test failure in migrations tests on OS X
Reported by: | Julien Phalip | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | info+coding@…, cmawebsite@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm seeing a test failure on Python 3.3.6 and 3.4.2 (it passes with 2.7.3):
====================================================================== FAIL: test_makemigrations_with_custom_name (migrations.test_commands.MakeMigrationsTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/django/tests/migrations/test_commands.py", line 545, in test_makemigrations_with_custom_name content = cmd("0002", migration_name_0002, "--empty") File "/django/tests/migrations/test_commands.py", line 531, in cmd self.assertTrue(os.path.exists(migration_file)) AssertionError: False is not true ----------------------------------------------------------------------
The issue is that the following migration files get created:
$ ls tests/migrations/migrations_21/ 0001_my_custom_migration.py 0001_my_initial_migration.py __init__.py
Note that my_custom_migration.py
starts with 0001_
whereas it should start with 0002_
. I'm unsure why this wasn't detected by the CI builds. Perhaps there's something broken in my environment but I really don't see what that could be.
Again, this works for me in 2.7 but fails in Python 3.
Change History (13)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
It's odd. Adding the following sleep()
statement allows the tests to consistently pass again:
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index f4e3878..a23f05a 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -519,6 +519,7 @@ class MakeMigrationsTests(MigrationTestBase): Makes sure that makemigrations generate a custom migration. """ def cmd(migration_count, migration_name, *args): + from time import sleep; sleep(1) with override_settings(MIGRATION_MODULES={"migrations": self.migration_pkg}): try: call_command("makemigrations", "migrations", "--verbosity", "0", "--name", migration_name, *args)
So this seems like some sort of race condition. It's unclear to me how that could be happening though...
comment:3 by , 10 years ago
Cc: | added |
---|
comment:5 by , 10 years ago
There seems to be some conflicts or side-effects between test_makemigrations_migrations_modules_path_not_exist
and test_makemigrations_with_custom_name
. If I comment out the former, then the latter passes. If I only run the two tests (runtests.py migrations.test_commands.MakeMigrationsTests.test_makemigrations_migrations_modules_path_not_exist migrations.test_commands.MakeMigrationsTests.test_makemigrations_with_custom_name
), then I see the failure.
Could you try running those two tests as in the command above?
comment:6 by , 10 years ago
Tried running just those two tests, using the command you gave in the last comment; still no failures here :/
comment:8 by , 10 years ago
Resolution: | worksforme |
---|---|
Status: | closed → new |
Triage Stage: | Unreviewed → Accepted |
Reported by Aymeric in #23970 (both he and Julien are on OS X and I think the other people that reported they couldn't reproduce this are on Linux).
comment:9 by , 10 years ago
Cc: | added |
---|---|
Summary: | Test failure in migrations tests → Test failure in migrations tests on OS X |
I can reproduce it on OS X. It happens every time.
comment:11 by , 10 years ago
Here's a script the reproduces the underlying behavior in python. I haven't nailed down exactly what versions/platforms are affected.
https://gist.github.com/collinanderson/6675dc9fdc0b84d80a49
comment:12 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:13 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I'm unable to reproduce the failure (Python 3.4.1+).