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

What's going on with these fixtures?

Brandon Taylor
  • 33,823
  • 15
  • 104
  • 144
  • I'm not sure, but can you try specified only fixture names in tests, like this: `fixtures = ['product_categories.json', 'brands.json', 'products.json']` – Alex Lisovoy Oct 07 '14 at 07:30
  • Moving the fixtures to: `/cart/fixtures` and changing the paths to only the file names does work. Sounds like there may be a bug with the fixture loader. – Brandon Taylor Oct 07 '14 at 14:25
  • I have opened a ticket regarding this issue: https://code.djangoproject.com/ticket/23612#ticket – Brandon Taylor Oct 07 '14 at 14:53

1 Answers1

0

So, the problem was that the path to the fixtures was not being normalized correctly in Windows. I submitted a pull request that was accepted, so this will hopefully go out in the next version of Django after 1.7.1

Brandon Taylor
  • 33,823
  • 15
  • 104
  • 144