我有一个 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
这些固定装置是怎么回事?