Ticket #17439: attribute_cache_test.diff

File attribute_cache_test.diff, 755 bytes (added by gwahl@…, 13 years ago)
  • tests/modeltests/one_to_one/tests.py

     
    121121        mm = MultiModel(link1=self.p2, link2=o1, name="x1")
    122122        self.assertRaises(IntegrityError, mm.save)
    123123        transaction.savepoint_rollback(sid)
     124
     125    def test_attribute_caching(self):
     126        # must do a query
     127        self.assertRaises(Restaurant.DoesNotExist, getattr, self.p2, 'restaurant')
     128
     129        # accessing the same attribute again should not do a query
     130        with self.assertNumQueries(0):
     131            self.assertRaises(Restaurant.DoesNotExist, getattr, self.p2, 'restaurant')
Back to Top