Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django从测试运行时忽略装置_Django_Unit Testing_Fixtures - Fatal编程技术网

Django从测试运行时忽略装置

Django从测试运行时忽略装置,django,unit-testing,fixtures,Django,Unit Testing,Fixtures,我在Django应用程序中有一个名为“project”的简单类 从django.test导入TestCase class ProjectTest(TestCase): """Unit tests for the "Project" app """ fixtures = ['test_data.json', ] def setUp(self): pass def testTotalAmountOfWhuffie(self): """Tests that the calcul

我在Django应用程序中有一个名为“project”的简单类


从django.test导入TestCase

class ProjectTest(TestCase):
"""Unit tests for the "Project" app """

fixtures = ['test_data.json', ]

def setUp(self):
    pass

def testTotalAmountOfWhuffie(self):
    """Tests that the calculation to find the total amount of Whuffie allocated is correct."""
    pass

if __name__ == '__main__':
    unittest.main()

当我跑的时候

manage.py测试项目

它完全忽略了固定装置。如果我将该文件重命名为initial_data.json,它将被测试运行程序获取,因此我确信目录结构是正确的


如果我增加测试运行的详细程度,他们甚至不会查找我指定的fixture,我甚至可以指定文件的完整路径,他们也不会被加载。

如果“test_data.json”在project/fixtures下,那么我看不出您所得到的有任何问题。尝试在测试中使用夹具数据

“它完全忽略了设备”

你怎么知道的

“如果我将该文件重命名为initial_data.json,它将被测试运行程序拾取”

只有测试运行程序运行syncdb时才会选择此选项。看

如果我增加测试运行的详细程度,他们甚至不会查找我指定的装置

你怎么能肯定?我将详细度设置为3来运行测试,测试运行者根本没有提到我的装置。(测试工作)
我甚至试着在测试中使用一个不存在的夹具。同样,测试运行人员没有提到任何问题。

您能列出您的目录结构吗?示例代码的缩进不正确,但我假设这只是问题的格式(请检查此处:)。你们的固定装置具体在哪里?是否在settings.py中设置了FIXTURE_DIRS?你能用loaddata()加载装置吗?这一行调试真的很混乱。装置已加载,尽管输出表明它们未加载。我明白原因。syncdb输出和测试输出之间没有明显的分离。