File tree Expand file tree Collapse file tree 2 files changed +40
-11
lines changed Expand file tree Collapse file tree 2 files changed +40
-11
lines changed Original file line number Diff line number Diff line change @@ -402,9 +402,17 @@ def teardown():
402402class _DirectMailboxAccessProtector (list ):
403403
404404 def _raise_assertion (* args , ** kwargs ):
405- raise AssertionError ('To access mail.outbox, use the mailoutbox fixture.' )
406-
407- __len__ = __getitem__ = __nonzero__ = __bool__ = _raise_assertion
405+ __tracebackhide__ = True
406+ raise AssertionError ('''To access mail.outbox, use the mailoutbox fixture.
407+ See http://pytest-django.readthedocs.io/en/latest/helpers.html#mailoutbox for more information.''' )
408+
409+ __len__ = _raise_assertion
410+ __getitem__ = _raise_assertion
411+ __nonzero__ = _raise_assertion
412+ __bool__ = _raise_assertion
413+ __eq__ = _raise_assertion
414+ __ne__ = _raise_assertion
415+ __iter__ = _raise_assertion
408416
409417
410418@pytest .fixture (autouse = True )
Original file line number Diff line number Diff line change 1919# to do it.
2020
2121
22- def test_direct_mailbox_access_not_allowed ():
23- with pytest .raises (AssertionError ):
24- len (mail .outbox )
22+ class Test_direct_mailbox_access_not_allowed ():
2523
26- with pytest .raises (AssertionError ):
27- mail .outbox [0 ]
24+ def test_len (self ):
25+ with pytest .raises (AssertionError ):
26+ len (mail .outbox )
2827
29- with pytest .raises (AssertionError ):
30- if mail .outbox :
31- pass
28+ def test_indexing (self ):
29+ with pytest .raises (AssertionError ):
30+ mail .outbox [0 ]
31+
32+ def test_bool (self ):
33+ with pytest .raises (AssertionError ):
34+ if mail .outbox :
35+ pass
36+
37+ def test_equality (self ):
38+ with pytest .raises (AssertionError ):
39+ mail .outbox == 'whatever'
40+
41+ def test_not_equality (self ):
42+ with pytest .raises (AssertionError ):
43+ mail .outbox != 'whatever'
44+
45+ def test_unpacking (self ):
46+ with pytest .raises (AssertionError ):
47+ (foo ,) = mail .outbox
48+
49+ def test_iteration (self ):
50+ with pytest .raises (AssertionError ):
51+ for x in mail .outbox :
52+ pass
3253
3354
3455def test_direct_mailbox_proection_should_not_break_sending_mail ():
You can’t perform that action at this time.
0 commit comments