Closed igorsobreira closed 9 years ago
+1
I've been having a look at this and there are two things that need handling:
I'll have a bit of a play to see what I can do to get this working, but I have no experience with pytest.
Right, I have the tests running with setup()
being called, however I run into an issue probably related to Python paths:
======================================================================================== ERRORS =========================================================================================
_________________________________________________________________________ ERROR collecting tests/test_admin.py __________________________________________________________________________
tests/test_admin.py:16: in <module>
from sampleproject.posts.models import Post, Comment, Tag, Multimedia
sampleproject/posts/models.py:4: in <module>
class Post(models.Model):
.tox/py27-django17/local/lib/python2.7/site-packages/django/db/models/base.py:176: in __new__
new_class.add_to_class(obj_name, obj)
.tox/py27-django17/local/lib/python2.7/site-packages/django/db/models/base.py:310: in add_to_class
value.contribute_to_class(cls, name)
.tox/py27-django17/local/lib/python2.7/site-packages/django/db/models/fields/related.py:2528: in contribute_to_class
self.rel.through = create_many_to_many_intermediary_model(self, cls)
.tox/py27-django17/local/lib/python2.7/site-packages/django/db/models/fields/related.py:2091: in create_many_to_many_intermediary_model
db_constraint=field.rel.db_constraint,
.tox/py27-django17/local/lib/python2.7/site-packages/django/db/models/base.py:295: in __new__
new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
.tox/py27-django17/local/lib/python2.7/site-packages/django/apps/registry.py:221: in register_model
(model_name, app_label, app_models[model_name], model))
E RuntimeError: Conflicting 'post_tags' models in application 'posts': <class 'posts.models.Post_tags'> and <class 'sampleproject.posts.models.Post_tags'>.
i'm not entirely sure why, but the tests are trying to import posts.models.Post_tags
and sampleprojects.posts.models.Post_tags
, seeing they have the same name and causing a conflict (even though they're the same class). I don't know if it's possibly due to where setup()
is being called in the manager
script.
Hi @scott-w, I had the same problem. The solution was to ensure the model is imported always the same way, see my change to file tests/test_admin.py
in the commit above.
All tests are passing with 1.7. Can you play with it in your project to make sure everything is ok before I create a new tag? Thanks for help!
Hi, I have it all working nicely on mine. I must have completely missed that when I was looking :+1:
As an aside, tox installs Django 1.8 for some reason by default, even though django>=1.7<1.8
is specified. Any idea why that is?
Weird, seems to be working for me
(py27-django17)igor@mac~/realgeeks/django-modelclone (master) ➥ pip freeze | grep -i django
Django==1.7.4
django-modelclone==0.4.0
django-webtest==1.7.7
pytest-django==2.8.0
Apologies I missed this reply. It's not a big deal, it could be something I set up but when I manually forced a Django 1.7 install it all works. Do you know when this version will be released? :)
Version 0.5.0 is in pypi and supports Django 1.7.
Great news! Cheers @igorsobreira
+1