@@ -218,31 +218,26 @@ def test_rolled_back_user_does_not_lead_to_foreign_key_error(self):
218
218
# happens, e.g. in test cases), and verifies that subsequently
219
219
# creating a new entry does not fail with a foreign key error.
220
220
221
- class Rollback (Exception ):
222
- pass
223
-
224
221
overridden_settings = {
225
222
'MIDDLEWARE_CLASSES' :
226
223
settings .MIDDLEWARE_CLASSES
227
224
+ ['simple_history.middleware.HistoryRequestMiddleware' ],
228
225
}
229
226
with override_settings (** overridden_settings ):
230
- try :
231
- with atomic ():
232
- user = User .objects .create_superuser (
233
- 'tmp' ,
'[email protected] ' ,
'pass' )
234
- self .assertTrue (self .client .login (username = 'tmp' , password = 'pass' ))
235
- self .app .get (reverse ('admin:tests_book_add' ))
236
- raise Rollback ()
237
- except Rollback :
238
- pass
227
+ self .login ()
228
+ self .assertEqual (
229
+ self .app .get (reverse ('admin:tests_book_add' )).status_code ,
230
+ 200 ,
231
+ )
239
232
240
233
book = Book .objects .create (isbn = "9780147_513731" )
241
- historical_book = book .history .all ()[0 ]
242
- self .assertIsNone (
243
- historical_book .history_user ,
244
- "No way to know of request, history_user should be unset." ,
245
- )
234
+
235
+ historical_book = book .history .all ()[0 ]
236
+
237
+ self .assertIsNone (
238
+ historical_book .history_user ,
239
+ "No way to know of request, history_user should be unset." ,
240
+ )
246
241
247
242
def test_middleware_anonymous_user (self ):
248
243
overridden_settings = {
0 commit comments