[Django] #23612: Relative fixture paths not working on Windows 8.1

18 views
Skip to first unread message

Django

unread,
Oct 7, 2014, 10:52:43 AM10/7/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------
Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Keywords: windows fixtures
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------
I have a Django 1.6.6 project that is not loading fixtures from relative
paths using Python 2.7.8 on Windows 8.1. Works just fine in Linux.

Example Test Case:

# cart/tests.py

class CartTestBase(TestCase):
fixtures = ['products/fixtures/product_categories.json',
'products/fixtures/brands.json',
'products/fixtures/products.json']

Which fits into a directory structure of:

ecomm_app/
cart/
__init__.py
models.py
tests.py
. . .

products/
fixtures/
products/fixtures/product_categories.json
products/fixtures/brands.json
products/fixtures/products.json
__init__.py
models.py
. . .

The specific error message is:

UserWarning: No fixture named 'products/fixtures/products' found.
warnings.warn("No fixture named '%s' found." % fixture_name)

The corresponding app modules are listed in `INSTALLED_APPS` and work fine
otherwise. Specifying an absolute path does work, but obviously isn't
cross-platform. Specifying a root-relative path does not work, e.g.:
`/products/fixtures/brands.json`

Moving the fixtures to `/cart/fixtures/` and referencing them by name only
works.

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

Django

unread,
Oct 7, 2014, 11:05:47 AM10/7/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+--------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:

Keywords: windows fixtures | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by charettes):

* needs_docs: => 0
* needs_tests: => 0
* needs_better_patch: => 0


Old description:

New description:

I have a Django 1.6.6 project that is not loading fixtures from relative
paths using Python 2.7.8 on Windows 8.1. Works just fine in Linux.

Example Test Case:

{{{#!python
# cart/tests.py

--

Comment:

First I assume the files in `products/fixtures/` are named `<name>.json`
and not `products/fixtures/<name>.json`.

I don't have Windows VM at hand but isn't it using backslashes (`\`) as
directory separators?

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

Django

unread,
Oct 7, 2014, 11:40:47 AM10/7/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+--------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:

Keywords: windows fixtures | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by alsoicode):

That is correct. I took a look at the directories returned by
`fixture_dirs()` in `core/management/loaddata.py` and the paths are
correct, but it doesn't seem to be concatenating the paths correctly if I
specify a directory structure plus the file name.

The paths returned by `fixture_dirs()` are in: `C:\\path\\path\\path`
format.

Leaving the directory structure off entirely works as it picks up the
`products/fixtures/` directory, but you'd most likely run into issues if
there were fixtures with duplicate names.

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

Django

unread,
Oct 7, 2014, 11:56:29 AM10/7/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+--------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:

Keywords: windows fixtures | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by alsoicode):

I think the problem is with line 183 in loaddata.py. It's checking for
`os.path.sep` which on Windows is `\`. Aren't we always supposed to use
forward slashes `/` with Python on Windows? Changing `os.path.sep` to `/`
allows the relative paths to work.

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

Django

unread,
Oct 7, 2014, 1:48:46 PM10/7/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+--------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:

Keywords: windows fixtures | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by alsoicode):

How about changing line 183 to:


{{{
if os.path.sep in os.path.normpath(fixture_name):
}}}

That way it is still based on the path separator for the os. Paths to
fixtures can still be written using `/` so they are consistent with other
paths in Django like template and static file directories, where the
documentation specifically states to use forward slashes.

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

Django

unread,
Oct 7, 2014, 2:28:26 PM10/7/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: windows fixtures | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by charettes):

* version: 1.7 => master
* stage: Unreviewed => Accepted


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

Django

unread,
Oct 7, 2014, 2:29:45 PM10/7/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: windows fixtures | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by alsoicode):

I submitted a Pull Request with a fix:
https://github.com/django/django/pull/3324

Running the test suite yields no failures.

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

Django

unread,
Oct 7, 2014, 3:06:04 PM10/7/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: windows fixtures | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by collinanderson):

* has_patch: 0 => 1


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

Django

unread,
Oct 9, 2014, 2:59:04 PM10/9/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------
Reporter: alsoicode | Owner: nobody
Type: Bug | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: windows fixtures | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"16ed35fafc0583b485a0289afda632f8261ecc96"]:
{{{
#!CommitTicketReference repository=""
revision="16ed35fafc0583b485a0289afda632f8261ecc96"
Fixed #23612 -- Normalized fixuture paths to allow referencing relative
paths on Windows.
}}}

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

Django

unread,
Oct 10, 2014, 4:27:25 AM10/10/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------
Reporter: alsoicode | Owner: nobody

Type: Bug | Status: closed
Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed
Keywords: windows fixtures | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by jaap3):

The test introduced with this fix doesn't pass. Created a separate ticket
#23633

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

Django

unread,
Oct 10, 2014, 8:57:15 AM10/10/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:

Keywords: windows fixtures | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

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


Comment:

I think we should try to make this test work when running tests via
`./tests/runtests.py` since all the other tests work and we have made
similar efforts to fix tests that didn't (e.g.
d11e83620380fdd98679b09062eefd25f0a98e21).

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

Django

unread,
Oct 21, 2014, 8:55:18 PM10/21/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: windows fixtures | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by timgraham):

Here's a [https://github.com/django/django/pull/3406 PR] to allow the
above.

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

Django

unread,
Oct 22, 2014, 3:26:22 PM10/22/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------

Reporter: alsoicode | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: windows fixtures | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"28da093ae24c3fb9070055df5d727a9c51c9cf83"]:
{{{
#!CommitTicketReference repository=""
revision="28da093ae24c3fb9070055df5d727a9c51c9cf83"
Allowed test from refs #23612 to be run from a directory other than tests.
}}}

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

Django

unread,
Oct 22, 2014, 3:26:51 PM10/22/14
to django-...@googlegroups.com
#23612: Relative fixture paths not working on Windows 8.1
-----------------------------------+------------------------------------
Reporter: alsoicode | Owner: nobody
Type: Bug | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: windows fixtures | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

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


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

Reply all
Reply to author
Forward
0 new messages