<s> from __future__ import absolute_import <EOL> from django . db import transaction , IntegrityError , DatabaseError <EOL> from django . test import TestCase <EOL> from . models import ( Counter , WithCustomPK , InheritedCounter , ProxyCounter , <EOL> SubCounter ) <EOL> class ForceTests ( TestCase ) : <EOL> def test_force_update ( self ) : <EOL> c = Counter . objects . create ( name = "<STR_LIT>" , value = <NUM_LIT:1> ) <EOL> c . value = <NUM_LIT:2> <EOL> c . save ( ) <EOL> c . value = <NUM_LIT:3> <EOL> c . save ( force_update = True ) <EOL> c . value = <NUM_LIT:4> <EOL> self . assertRaises ( ValueError , c . save , force_insert = True , force_update = True ) <EOL> c1 = Counter ( name = "<STR_LIT>" , value = <NUM_LIT:2> ) <EOL> self . assertRaises ( ValueError , c1 . save , force_update = True ) <EOL> c1 . save ( force_insert = True ) <EOL> sid = transaction . savepoint ( ) <EOL> c . value = <NUM_LIT:5> <EOL> self . assertRaises ( IntegrityError , c . save , force_insert = True ) <EOL> transaction . savepoint_rollback ( sid ) <EOL> obj = WithCustomPK ( name = <NUM_LIT:1> , value = <NUM_LIT:1> ) <EOL> self . assertRaises ( DatabaseError , obj . save , force_update = True ) <EOL> class InheritanceTests ( TestCase ) : <EOL> def test_force_update_on_inherited_model ( self ) : <EOL> a = InheritedCounter ( name = "<STR_LIT:count>" , value = <NUM_LIT:1> , tag = "<STR_LIT>" ) <EOL> a . save ( ) <EOL> a . save ( force_update = True ) <EOL> def test_force_update_on_proxy_model ( self ) : <EOL> a = ProxyCounter ( name = "<STR_LIT:count>" , value = <NUM_LIT:1> ) <EOL> a . save ( ) <EOL> a . save ( force_update = True ) <EOL> def test_force_update_on_inherited_model_without_fields ( self ) : <EOL> '''<STR_LIT>''' <EOL> a = SubCounter ( name = "<STR_LIT:count>" , value = <NUM_LIT:1> ) <EOL> a . save ( ) <EOL> a . value = <NUM_LIT:2> <EOL> a . save ( force_update = True ) </s>
