~divmod-dev/divmod.org/index-traceback-2943

« back to all changes in this revision

Viewing changes to Axiom/axiom/test/test_reference.py

  • Committer: exarkun
  • Date: 2009-07-06 12:35:46 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:17687
Apply safer.patch

Author: exarkun
Reviewer: glyph
Fixes: #1964

Ensure that global state mutated by `test_brokenReferenceException` is restored to its
original value even if the test fails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
        self.assertEqual(referent.ref, None)
81
81
 
82
82
 
83
 
    def testBrokenReferenceException(self):
 
83
    def test_brokenReferenceException(self):
84
84
        """
85
85
        Test that an exception is raised when a broken reference is detected
86
86
        when this should be impossible (ie. CASCADE or NULLIFY).
95
95
        gc.collect()
96
96
 
97
97
        referent = store.findFirst(BreakingReferent)
98
 
        BreakingReferent.ref.whenDeleted = reference.CASCADE
 
98
        self.patch(BreakingReferent.ref, 'whenDeleted', reference.CASCADE)
99
99
        self.assertRaises(BrokenReference, lambda: referent.ref)
100
 
        BreakingReferent.ref.whenDeleted = reference.NULLIFY
 
100
 
101
101
 
102
102
    def testBadReferenceNoneRevert(self):
103
103
        store = Store()