I am facing this strange unittests random crash problem. I mainly test syndication channels
Here is the relevant part of my code:
class ObjectFeedTests(PuppyTestCase): def test_object_feeds(self): site = Site.objects.get_or_create(id=site_id)[0]
factory:
class ShowFactory(factory.Factory): FACTORY_FOR = Show title = factory.Sequence(lambda name: 'My Show {0}'.format(name)) slug = factory.Sequence(lambda name: 'my-show-{0}'.format(name)) creator = factory.SubFactory(UserFactory) last_editor = factory.SubFactory(UserFactory) site = factory.SubFactory(SiteFactory) status = STATUS_CHOICES.PUBLISHED
Each time I run the test, 3 factories are created and the tests are interrupted randomly.
If the local variable declaration is not indicated in the code, skip it, as I have reduced the code so that it is as small as possible.
I reviewed using this , but the results remained the same.
Please let me know if there is any information that I could provide.
Here is the crash stop trace:
====================================================================== FAIL: test_object_feeds (tests.syndication_tests.ObjectFeedTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "tests/cases.py", line 44, in run testMethod() File "tests/syndication_tests.py", line 370, in test_object_feeds presumed_url)) File "/usr/local/virtualenvs/lib/python2.6/site-packages/django/test/testcases.py", line 622, in assertContains " (expected %d)" % (response.status_code, status_code)) AssertionError: 404 != 200 : people rss feed raised a 404 or wasn't XML (tried /feeds/show/test-show-0): Couldn't retrieve content: Response code was 404 (expected 200) ---------------------------------------------------------------------- Ran 5 tests in 10.613s FAILED (failures=1) Destroying test database for alias 'default'...
The next time I started it,
====================================================================== FAIL: test_object_feeds (tests.syndication_tests.ObjectFeedTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "tests/cases.py", line 44, in run testMethod() File "tests/syndication_tests.py", line 370, in test_object_feeds presumed_url)) File "/usr/local/virtualenvs/lib/python2.6/site-packages/django/test/testcases.py", line 622, in assertContains " (expected %d)" % (response.status_code, status_code)) AssertionError: 404 != 200 : channels rss feed raised a 404 or wasn't XML (tried /feeds/show/test-show-1): Couldn't retrieve content: Response code was 404 (expected 200) ---------------------------------------------------------------------- Ran 5 tests in 3.483s FAILED (failures=1) Destroying test database for alias 'default'...