Best Python code snippet using pytest-play_python
test_metrics.py
Source:test_metrics.py  
...309    assert provider.engine is mock_engine310    time_start = 1550770816.1716287311    with mock.patch('pytest_play.providers.metrics.time') as time:312        time.time.return_value = time_start313        provider.command_record_elapsed_start({314            'provider': 'metrics',315            'type': 'record_elapsed_start',316            'name': 'async_update',317        })318    assert mock_engine.update_variables.assert_called_once_with(319        {'async_update': time_start}) is None320def test_record_elapsed_stop():321    import mock322    mock_engine = mock.MagicMock()323    time_start = 1550770816.1716287324    mock_engine.variables = {'async_update': time_start}325    mock_record_property = mock.MagicMock()326    mock_record_property_statsd = mock.MagicMock()327    from pytest_play import providers...metrics.py
Source:metrics.py  
...54        value = self.engine.variables['_elapsed']55        self.engine.update_variables({name: value})56        self.record_property(name, value, metric_type='timing',57                             meas_unit='s')58    def command_record_elapsed_start(self, command, **kwargs):59        """ record a time delta (start tracking time) """60        name = command['name']61        self.engine.update_variables({name: time.time()})62    def command_record_elapsed_stop(self, command, **kwargs):63        """ record a time delta (end tracking time) """64        name = command['name']65        delta = time.time() - self.engine.variables[name]66        self.engine.update_variables({name: delta})67        self.record_property(name, delta, metric_type='timing',...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!!
