Ticket #4788: skipped_test_deco_r8069.diff
File skipped_test_deco_r8069.diff, 2.4 KB (added by , 16 years ago) |
---|
-
django/test/__init__.py
4 4 5 5 from django.test.client import Client 6 6 from django.test.testcases import TestCase 7 8 class SkippedTest(Exception): 9 pass 10 No newline at end of file -
django/test/decorators.py
1 from django.core import urlresolvers 2 from django.test import SkippedTest 3 4 def views_required(required_views=[]): 5 def urls_found(): 6 try: 7 for view in required_views: 8 url = urlresolvers.reverse(view) 9 return True 10 except urlresolvers.NoReverseMatch: 11 return False 12 return conditional_skip(urls_found) 13 14 def conditional_skip(required_condition): 15 if required_condition(): 16 return lambda x: x 17 else: 18 return skip_test 19 20 def skip_test(function): 21 def _skip(x): 22 raise SkippedTest 23 return _skip 24 No newline at end of file -
django/contrib/auth/tests/basic.py
56 56 """ 57 57 58 58 from django.test import TestCase 59 from django.test.decorators import views_required 59 60 from django.core import mail 60 61 61 62 class PasswordResetTest(TestCase): 62 63 fixtures = ['authtestdata.json'] 63 64 urls = 'django.contrib.auth.urls' 64 65 66 @views_required(required_views=['django.contrib.auth.views.password_reset']) 65 67 def test_email_not_found(self): 66 68 "Error is raised if the provided email address isn't currently registered" 67 69 response = self.client.get('/password_reset/') … … 70 72 self.assertContains(response, "That e-mail address doesn't have an associated user account") 71 73 self.assertEquals(len(mail.outbox), 0) 72 74 75 @views_required(required_views=['django.contrib.auth.views.password_reset']) 73 76 def test_email_found(self): 74 77 "Email is sent if a valid email address is provided for password reset" 75 78 response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})