Reputation: 1122
I have a model called TestCase
(I know....), and I'd like to test it in my suite of tests.
class TestTestCase(TestCase):
def setUp(self):
self.test_case = mommy.make('main.TestCase')
def test_property1(self):
self.assertEqual(self.test_case.property1, 'foo_bar')
Running my test, I get :
RuntimeError: Conflicting 'c' models in application 'nose': <class 'main.models.TestCase'> and <class 'nose.util.C'>.
How can I make these kind of tests pass without renaming my model?
Upvotes: 1
Views: 81
Reputation: 19902
When importing a Python module, Python allows you to alter the imported name in order to avoid name conflicts:
from x2 import y
from x import y as z
Then you will be able to refer to the imported module x.y as z without conficting with the x2.y module.
Upvotes: 2