How to use command_assert method in pytest-play

Best Python code snippet using pytest-play_python

test_python.py

Source:test_python.py Github

copy

Full Screen

...19def test_assertion(expression, play):20 play.variables = {'foo': 'baz'}21 from pytest_play import providers22 provider = providers.PythonProvider(play)23 provider.command_assert({24 'provider': 'python',25 'type': 'assert',26 'expression': expression27 })28def test_assertion_ko(play):29 play.variables = {'foo': 'baz'}30 from pytest_play import providers31 provider = providers.PythonProvider(play)32 with pytest.raises(AssertionError):33 provider.command_assert({34 'provider': 'python',35 'type': 'assert',36 'expression': '200 == 404'37 })38@pytest.mark.parametrize('expression', [39 'open("/etc/passwd", "r")',40 'open',41 'import os',42 '__file__',43 '__file__',44 '__builtins__.__dict__["bytes"]',45 '__builtins__.__dict__["bytes"] = "pluto"',46 'prova = lambda: 1',47 'os = 1',48])49def test_assertion_bad(expression, play):50 play.variables = {'foo': 'baz'}51 from pytest_play import providers52 provider = providers.PythonProvider(play)53 with pytest.raises(Exception):54 provider.command_assert({55 'provider': 'python',56 'type': 'assert',57 'expression': expression58 })59def test_store_variable(play):60 play.variables = {'foo': 'baz'}61 from pytest_play import providers62 provider = providers.PythonProvider(play)63 provider.command_store_variable({64 'provider': 'python',65 'type': 'store_variable',66 'expression': '1+1',67 'name': 'sum2'68 })69 assert 'sum2' in play.variables70 assert play.variables['foo'] == 'baz'71 assert play.variables['sum2'] == 272def test_exec(play):73 play.variables = {'foo': 'baz'}74 from pytest_play import providers75 provider = providers.PythonProvider(play)76 assert provider.command_exec({77 'provider': 'python',78 'type': 'exec',79 'expression': '1+1',80 }) == 281@pytest.mark.parametrize('expression', [82 'variable == 200',83])84def test_assertion_kwargs(expression, play):85 play.variables = {'foo': 'baz'}86 assert 'variable' not in play.variables87 from pytest_play import providers88 provider = providers.PythonProvider(play)89 provider.command_assert({90 'provider': 'python',91 'type': 'assert',92 'expression': expression93 },94 variable=200)95 assert 'variable' not in play.variables96def test_sleep(play):97 play.variables = {}98 from pytest_play import providers99 provider = providers.PythonProvider(play)100 from datetime import (101 datetime,102 timedelta,103 )...

Full Screen

Full Screen

SConscript

Source:SConscript Github

copy

Full Screen

...36 if os.path.exists(v8_git_dir) and os.path.isdir(v8_git_dir):37 print "ok."38 else:39 print "not found."40 utils.command_assert(['rm', '-rf', v8_dir])41 print "Cloning v8."42 utils.command_assert(['git', 'clone', v8_remote, v8_dir],43 "Failed to clone v8. Aborting build.")44def v8_build(target, source, env):45 print "Building v8. This may take some time."46 print ' '.join(['make', '-C', v8_dir, '-j3', 'dependencies'])47 utils.command_assert(['make', '-C', v8_dir, '-j3', 'dependencies'],48 "Failed to build v8 dependencies. Aborting build.")49 print ' '.join(['make', '-C', v8_dir, '-j3', 'native'])50 utils.command_assert(['make', '-C', v8_dir, '-j3', 'native'],51 "Failed to build v8. Aborting build.")52v8_repo = local_env.Command(v8_git_dir, '', v8_clone)53v8_engine = local_env.Command(v8_engine_path, v8_repo, v8_build)54v8_sources = Glob(os.path.join(v8_dir, 'src', '*')) + Glob(os.path.join(v8_dir, 'src', 'x64', '*')) + Glob(os.path.join(v8_dir, 'src', 'ia32', '*'))55Depends(v8_engine, v8_sources)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-play automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful