mamba的Django测试运行程序(Python的最终测试运行程序)。

mamba-django的Python项目详细描述


曼巴江戈

PyPI pyversions

mamba的Django测试运行程序。在

如何安装

pip install mamba-django

如何使用

转到您的Django测试设置并添加以下行

^{pr2}$

然后执行Django测试

./manage.py test --settings=project.settings.test --keepdb

或者您可以执行将其作为参数传递的测试

./manage.py test --testrunner mamba_django.MambaRunner --settings=project.settings.test --keepdb

此外,还可以将所有mamba参数传递给Django test命令。在

例如:

./manage.py test --settings=project.settings.test --keepdb -f documentation -s 1

如何使用Django数据库事务执行mamba测试

fromexpectsimport(equal,expect)frommamba_djangoimport(start_django_transactions,rollback_django_transactions)frommyapp.modelsimportAnimalwithdescription("Mamba with Django")asself:withbefore.each:self.transactions=start_django_transactions()withcontext("Running atomic tests"):withit("creates an animal"):Animal.objects.create(name="lion",sound="roar")expect(Animal.objects.all().count()).to(equal(1))withit("creates another animal"):Animal.objects.create(name="lion",sound="roar")expect(Animal.objects.all().count()).to(equal(1))withafter.each:rollback_django_transactions(self.transactions)

如何加载Django设备

您可以使用方法load_fixtures来加载Django fixtures。在

fromexpectsimport(equal,expect)frommamba_djangoimport(load_fixtures,start_django_transactions,rollback_django_transactions)fromdjango.contrib.auth.modelsimportGroupwithdescription("Mamba with Django")asself:withbefore.each:self.transactions=start_django_transactions()load_fixtures(['group.json'])withcontext("Fixtures"):withit("can retrieve loaded fixtures"):expect(Group.objects.all().count()).to(equal(1))withafter.each:rollback_django_transactions(self.transactions)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何强制用户在允许访问活动之前处理对话框?我的许可证代码怎么了?   java ArraysList作为JSON   mysql如何在java中创建包含多个可选where子句的搜索语句?   java如何让Apache Camel在“直接”路径的末尾删除文件?   使用socket在两个Androids之间进行java实时数据传输。IO(websocket)和4G   如何在java中实现两个CORBA服务器之间的通信   会话树xml表示为java对象   java Skype4Java编号swtwin323325   java RecyclerView getAdapterPosition()不工作:第一次单击返回正确位置,第二次单击返回1   java在$TOMCAT/conf/context上为JNDI设置资源。xml   java为什么第二个矩形冲突在第一个矩形冲突时不起作用?   JScrollPane上的java JTextArea未出现在JPanel上   java如何将实现的PriorityQueue打印为字符串?   jpa使用Jersey更新用户角色RESTJava(JAXRS)