0

我有一个 Django 1.6.6 项目,它没有在 Windows 8.1 上使用 Python 2.7.8 从相对路径加载固定装置。在 Linux 中工作得很好。

示例测试用例:

# cart/tests.py

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

它适合以下目录结构:

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
        . . .

具体的错误信息是:

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

相应的应用程序模块已列出,INSTALLED_APPS否则可以正常工作。指定绝对路径确实有效,但显然不是跨平台的。指定根相对路径不起作用,例如:/products/fixtures/brands.json

这些固定装置是怎么回事?

4

1 回答 1

0

所以,问题是在 Windows 中,灯具的路径没有被正确规范化。我提交了一个被接受的拉取请求,所以这有望在 1.7.1 之后的下一个版本的 Django 中消失

于 2014-11-08T20:42:49.237 回答