def test_exec(play): play.variables = {'foo': 'baz'} from pytest_play import providers provider = providers.PythonProvider(play) assert provider.command_exec({ 'provider': 'python', 'type': 'exec', 'expression': '1+1', }) == 2
def test_sleep_float(sleep_time, play): play.variables = {} from pytest_play import providers provider = providers.PythonProvider(play) provider.command_sleep({ 'provider': 'python', 'type': 'sleep', 'seconds': sleep_time })
def test_assertion(expression, play): play.variables = {'foo': 'baz'} from pytest_play import providers provider = providers.PythonProvider(play) provider.command_assert({ 'provider': 'python', 'type': 'assert', 'expression': expression })
def test_assertion_ko(play): play.variables = {'foo': 'baz'} from pytest_play import providers provider = providers.PythonProvider(play) with pytest.raises(AssertionError): provider.command_assert({ 'provider': 'python', 'type': 'assert', 'expression': '200 == 404' })
def test_exec(): import mock mock_engine = mock.MagicMock() mock_engine.variables = {'foo': 'baz'} from pytest_play import providers provider = providers.PythonProvider(mock_engine) assert provider.engine is mock_engine assert provider.command_exec({ 'provider': 'python', 'type': 'exec', 'expression': '1+1', }) == 2
def test_assertion(expression): import mock mock_engine = mock.MagicMock() mock_engine.variables = {'foo': 'baz'} from pytest_play import providers provider = providers.PythonProvider(mock_engine) assert provider.engine is mock_engine provider.command_assert({ 'provider': 'python', 'type': 'assert', 'expression': expression })
def test_sleep_float(sleep_time): import mock mock_engine = mock.MagicMock() mock_engine.variables = {} from pytest_play import providers provider = providers.PythonProvider(mock_engine) assert provider.engine is mock_engine provider.command_sleep({ 'provider': 'python', 'type': 'sleep', 'seconds': sleep_time })
def test_assertion_kwargs(expression, play): play.variables = {'foo': 'baz'} assert 'variable' not in play.variables from pytest_play import providers provider = providers.PythonProvider(play) provider.command_assert( { 'provider': 'python', 'type': 'assert', 'expression': expression }, variable=200) assert 'variable' not in play.variables
def test_store_variable(play): play.variables = {'foo': 'baz'} from pytest_play import providers provider = providers.PythonProvider(play) provider.command_store_variable({ 'provider': 'python', 'type': 'store_variable', 'expression': '1+1', 'name': 'sum2' }) assert 'sum2' in play.variables assert play.variables['foo'] == 'baz' assert play.variables['sum2'] == 2
def test_assertion_ko(): import mock mock_engine = mock.MagicMock() mock_engine.variables = {'foo': 'baz'} from pytest_play import providers provider = providers.PythonProvider(mock_engine) assert provider.engine is mock_engine with pytest.raises(AssertionError): provider.command_assert({ 'provider': 'python', 'type': 'assert', 'expression': '200 == 404' })
def test_store_variable(): import mock mock_engine = mock.MagicMock() mock_engine.variables = {'foo': 'baz'} from pytest_play import providers provider = providers.PythonProvider(mock_engine) assert provider.engine is mock_engine provider.command_store_variable({ 'provider': 'python', 'type': 'store_variable', 'expression': '1+1', 'name': 'sum2' }) assert 'sum2' in mock_engine.variables assert mock_engine.variables['foo'] == 'baz' assert mock_engine.variables['sum2'] == 2
def test_sleep(play): play.variables = {} from pytest_play import providers provider = providers.PythonProvider(play) from datetime import ( datetime, timedelta, ) now = datetime.now() provider.command_sleep({ 'provider': 'python', 'type': 'sleep', 'seconds': 2 }) now_now = datetime.now() expected_date = now + timedelta(milliseconds=2000) assert now_now >= expected_date
def test_sleep(): import mock mock_engine = mock.MagicMock() mock_engine.variables = {} from pytest_play import providers provider = providers.PythonProvider(mock_engine) assert provider.engine is mock_engine from datetime import ( datetime, timedelta, ) now = datetime.now() provider.command_sleep({ 'provider': 'python', 'type': 'sleep', 'seconds': 2 }) now_now = datetime.now() expected_date = now + timedelta(milliseconds=2000) assert now_now >= expected_date