I have a test that is failing when the file it is in is run as part of all
the other test files by the test runner.

If I just run only the file that contains this test -  then it passes.

(pass/fail refers to the very last assert in the code below.)

I'd appreciate any ideas or insights from anyone who can spot an obvious
mistake - or suggest some options to explore.

Thanks
Derek


# THIS IS AN EXTRACT OF RELEVANT CODE (not all of it...)
from django.contrib.messages.storage.fallback import FallbackStorage
from django.core.urlresolvers import reverse
from django.test import TestCase, Client
# ... various app-related imports ...


class MockRequest(object):
    """No code needed."""
    pass


REQUEST = MockRequest()
# see: https://stackoverflow.com/queI stions/11938164/why-dont-my-django-\
#      unittests-know-that-messagemiddleware-is-installed
setattr(REQUEST, 'session', 'session')
MESSAGES = FallbackStorage(REQUEST)
setattr(REQUEST, '_messages', MESSAGES)
setup_test_environment()


class PersonAdminTest(TestCase):

    def setUp(self):
        self.user, password = utils.user_factory(model=None)
        self.client = Client()
        login_status = self.client.login(username=self.user.email,
password=password)
        self.assertEqual(login_status, True)

    def test_action_persons_make_unreal(self):
        try:
            change_url = reverse('admin:persons_realpersons_changelist')
        except NoReverseMatch:
            change_url = '/admin/persons/realpersons/'
            sys.stderr.write('\n   WARNING: Unable to reverse URL! ... ')
        response = self.client.get(change_url)
        self.assertEqual(response.status_code, 200)

-- 
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/CAF1Wu3MoGgm_dSToObDX9gH7GQJ%3DTZzGLV7RPOiZk4kvV-_Nbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to