English 中文(简体)
进口两次
原标题:import twice when run test

i 在我的测试中加入这一法典。 py:

from models import *

和模式。 p. 我有信号手,在上面登记

post_save.connect( post_save_note, sender=Note )

以及当使用<代码>的测试时。

I found the signal handler was registered twice and executed twice, and I found it s because the models was imported twice.

can t i put from models import * in the test code? what should i do?

最佳回答

你们需要确保以同样的方式进口你的模型。

例如,如果在<条码>上填写>example1/tests.py:

from models import *

以及另一套文件example2/views.py:

from example1.models import ModelA

然后,你会遇到问题。 解决办法是前后一致的,只使用一种或另一种办法。

问题回答

暂无回答




相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...

热门标签