在测试执行和更改测试数据库表的情况下,数据库表会在每次测试后返回到原始状态吗?如果不是,我应该如何知道测试执行的顺序,以便我能够预测数据库表的状态。例如,Django测试执行顺序和表
class SimpleTest(Testcase):
def test_insert(self):
# testing to see if data correctly added to database
def test_other_thing(self):
# does insered data available here?
什么关于我在setUp方法中放入数据库的东西,我猜他们会留在表格中吗? – yasar
那么,'setUp'每个测试运行一次,而不是每个测试用例。所以db被清空,然后setUp再次运行。 –
@ yasar11732,在数据库回滚之后,'setUp'在下一次测试之前再次运行 –