Best Python code snippet using autotest_python
database_connection_unittest.py
Source:database_connection_unittest.py  
...114        params = object()115        self._fake_backend.execute.expect_call('query', params)116        db.execute('query', params)117        self.god.check_playback()118    def test_execute_retry(self):119        db = self._get_database_connection()120        self._simple_connect(db)121        self._fake_backend.execute.expect_call('query', None).and_raises(122            FakeDatabaseError())123        self._expect_reconnect()124        self._fake_backend.execute.expect_call('query', None)125        db.execute('query')126        self.god.check_playback()127        self._fake_backend.execute.expect_call('query', None).and_raises(128            FakeDatabaseError())129        self.assertRaises(FakeDatabaseError, db.execute, 'query',130                          try_reconnecting=False)131if __name__ == '__main__':132    unittest.main()test_requests.py
Source:test_requests.py  
...45            method='BLA'46        )47    assert not mocked_get.called48@patch('requests.get')49def test_execute_retry(mocked_get):50    """Test request retry."""51    mocked_get.side_effect = Mock(side_effect=[52        MagicMock(status_code=500, text=''),53        MagicMock(status_code=200, text='{}')54    ])55    response = request.execute(56        max_retries=4,57        retry_interval=0,58        url='blabla',59        method='GET'60    )61    assert response.status_code == 20062    assert response.text == '{}'63    assert mocked_get.call_count == 2...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
