(self)
| 268 | assert f._db_recycles == 1 |
| 269 | |
| 270 | def test__close_database(self): |
| 271 | with self.fixup_context(self.app) as (f, _, _): |
| 272 | conns = [Mock(), Mock(), Mock()] |
| 273 | conns[1].close.side_effect = KeyError('already closed') |
| 274 | f.DatabaseError = KeyError |
| 275 | f.interface_errors = () |
| 276 | |
| 277 | f._db.connections = Mock() # ConnectionHandler |
| 278 | f._db.connections.all.side_effect = lambda initialized_only: conns |
| 279 | |
| 280 | f._close_database() |
| 281 | conns[0].close.assert_called_with() |
| 282 | conns[1].close.assert_called_with() |
| 283 | conns[2].close.assert_called_with() |
| 284 | |
| 285 | conns[1].close.side_effect = KeyError( |
| 286 | 'omg') |
| 287 | with pytest.raises(KeyError): |
| 288 | f._close_database() |
| 289 | |
| 290 | def test__close_database_django_pre_41(self): |
| 291 | """Test that Django < 4.1 (without initialized_only parameter) is handled.""" |
nothing calls this directly
no test coverage detected