Opened 9 years ago
Closed 9 years ago
#27436 closed Bug (fixed)
migrations.test_commands.MakeMigrationsTests fail on Windows when run on a different drive than C:
| Reported by: | Zbigniew Siciarz | Owned by: | Zbigniew Siciarz |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | 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
Some of the test cases in MakeMigrationsTests fail on Windows due to inability to find a relative path between files located on separate drives.
The tests create a temporary migrations directory using tempfile.mkdtemp, which on Windows creates a directory under C:\Temp (or C:\Users\<username>\AppData\Local\Temp).
If one clones Django source code to a drive other than C:, then the makemigrations command tests fail with an error like the following (Windows 7, Python 3.5.1):
ERROR: test_makemigrations_non_interactive_not_null_alteration (migrations.test_commands.MakeMigrationsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\dev\django\tests\migrations\test_commands.py", line 834, in test_makemigrations_non_interactive_not_null_alteration
call_command("makemigrations", "migrations", interactive=False, stdout=out)
File "d:\dev\django\django\core\management\__init__.py", line 130, in call_command
return command.execute(*args, **defaults)
File "d:\dev\django\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "d:\dev\django\django\core\management\commands\makemigrations.py", line 193, in handle
self.write_migration_files(changes)
File "d:\dev\django\django\core\management\commands\makemigrations.py", line 211, in write_migration_files
migration_string = os.path.relpath(writer.path)
File "D:\Miniconda3\lib\ntpath.py", line 574, in relpath
path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'D:'
Since the value returned from relpath is used only for display and not for any I/O, I'd suggest catching this ValueError and using an absolute path in that case.
Change History (6)
comment:1 by , 9 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:2 by , 9 years ago
| Has patch: | set |
|---|
comment:3 by , 9 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:4 by , 9 years ago
| Keywords: | tests removed |
|---|---|
| Patch needs improvement: | set |
Left some comments for improvement.
comment:5 by , 9 years ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Patch and added test LGTM.
The following pull request fixes this issue: https://github.com/django/django/pull/7472