I apologize as I inadvertently submitted my last post and cant delete it. Any way: I am in the midst of writing unit tests for an application I am working on. My tests work fine on my 2012 Macbook pro but not my 2015 iMac. Both are running the latest OSX and the django version is version 1.9.1 with custom modifications that can be seen here: https://github.com/shuttl-io/django. The modifications where to the template loading mechanisms.
Before I move on, my tests are organized thusly: >app/ > tests/ > test_models/ > __init__.py > test_*.py > test_views/ > __init__.py > test_*.py > test_forms/ > test_*.py > __init__.py And in those init files I include all of the test_*.py files. Anyway, In my tests, I have a few mock classes inside of a test file of test_models. It appears that my 2012 MbP will makemigrations and migrate the test database with the mock classes into the test db. My test file looks like this: http://pastebin.com/m9VKDLhE. How ever on my iMac, the mock classes at the top of my file isn't migrated. So I read up on that issue and decided to add a testing app that was written somewhere. The tests have the same organization and the mock classes moved to models.py. Then in my settings.py file I have this snippet: if "test" in sys.argv: INSTALLED_APPS.append("testing") if "makemigrations" in sys.argv: ndx = sys.argv.index("test") sys.argv.pop(ndx) pass pass Based around the snippet posted in here: https://code.djangoproject.com/ticket/7835#trac-change-3-1226837305000000 Now this works and puts the mock files into the DB and gets rid of the OperationalError. However this adds more complex errors that I don't know about. Before I talk about the errors, Here is the class that is causing the errors:http://pastebin.com/n3906RC8. The publishable class it inherits from is not a model and is only a Abstract Base Class with a few methods that need to be implemented. Now the errors I got initially was this error: ====================================================================== ERROR: test_renderSite (testing.tests.test_webpage.test_models.test_webpage.WebsiteTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/Yoseph/shuttl/testing/tests/test_webpage/test_models/test_webpage.py", line 80, in test_renderSite siteMap = self.website.getSiteMap() File "/Users/Yoseph/shuttl/Webpage/models.py", line 155, in getSiteMap return self.root.render() File "/Users/Yoseph/shuttl/Webpage/models.py", line 252, in render for i in self.children: File "/Users/Yoseph/shuttl/Webpage/models.py", line 240, in children for i in Class.objects.filter(parent=self): File "/Users/Yoseph/.venv/shuttl/src/django/django/db/models/manager.py", line 122, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/Users/Yoseph/.venv/shuttl/src/django/django/db/models/query.py", line 790, in filter return self._filter_or_exclude(False, *args, **kwargs) File "/Users/Yoseph/.venv/shuttl/src/django/django/db/models/query.py", line 808, in _filter_or_exclude clone.query.add_q(Q(*args, **kwargs)) File "/Users/Yoseph/.venv/shuttl/src/django/django/db/models/sql/query.py", line 1243, in add_q clause, _ = self._add_q(q_object, self.used_aliases) File "/Users/Yoseph/.venv/shuttl/src/django/django/db/models/sql/query.py", line 1269, in _add_q allow_joins=allow_joins, split_subq=split_subq, File "/Users/Yoseph/.venv/shuttl/src/django/django/db/models/sql/query.py", line 1174, in build_filter self.check_related_objects(field, value, opts) File "/Users/Yoseph/.venv/shuttl/src/django/django/db/models/sql/query.py", line 1071, in check_related_objects self.check_query_object_type(value, opts, field) File "/Users/Yoseph/.venv/shuttl/src/django/django/db/models/sql/query.py", line 1055, in check_query_object_type (value, opts.object_name)) ValueError: Cannot query "root": Must be "Directory" instance. I printed out the type and it is a Directory instance. I solved this issue by changing for i in Class.objects.filter(parent=self): to for i in Class.objects.filter(parent_id=self.id): This fixed that error but caused a different error that made even less sense: ====================================================================== ERROR: test_renderSite (testing.tests.test_webpage.test_models.test_webpage.WebsiteTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/Yoseph/shuttl/testing/tests/test_webpage/test_models/test_webpage.py", line 90, in test_renderSite self.assertEqual(self.website.getSiteMap(), testMap) File "/Users/Yoseph/shuttl/Webpage/models.py", line 155, in getSiteMap return self.root.render() File "/Users/Yoseph/shuttl/Webpage/models.py", line 253, in render renderMap["children"].append(i.render()) AttributeError: 'Directory' object has no attribute 'render' ---------------------------------------------------------------------- If you refer to the second pastebin, you'll notice that the Directory class does actually have a render method. I am completely stumped. Do you guys have any guesses? Thanks in advance. Test File: http://pastebin.com/m9VKDLhE Model Snippet: http://pastebin.com/n3906RC8 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aa41466c-56d3-42fb-9b9f-7f7f750dd706%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.