在运行Django测试之前加载SQL转储 [英] Loading SQL dump before running Django tests

查看:112
本文介绍了在运行Django测试之前加载SQL转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当复杂的Django项目,这使得它很难/不可能使用fixture来加载数据。

I have a fairly complex Django project which makes it hard/impossible to use fixtures for loading data.

我想做的是加载数据库转储从生产数据库服务器之后,所有的表都由试用者创建并在实际测试开始运行之前。

What I would like to do is to load a database dump from the production database server after all tables has bene created by the testrunner and before the actual tests start running.

我在MyTestCase.setUp中尝试过各种魔术 ),但没有运气。

I've tried various "magic" in MyTestCase.setUp(), but with no luck.

任何建议将是最受欢迎的。谢谢。

Any suggestions would be most welcome. Thanks.

推荐答案

您可能需要查看定义一个自定义测试运行器。这里有一些信息: http:// docs。 djangoproject.com/en/dev/topics/testing/#using-different-testing-frameworks

You may need to look into defining a custom test runner. There's some info here: http://docs.djangoproject.com/en/dev/topics/testing/#using-different-testing-frameworks

基本上我认为你可以复制默认的测试运行从django.test.simple.run_tests然后修改它以满足您的需要。

Basically I think you can just copy the default test runner from django.test.simple.run_tests and then modify it to suit your needs.

我以前没有这样做,但从我的理解,将是定制这个。

I've not done this before, but from my understanding that would be the way to customize this.

这篇关于在运行Django测试之前加载SQL转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆