Skip to content

Instantly share code, notes, and snippets.

View parimooa's full-sized avatar

Ashish Parimoo parimooa

  • UK
  • 08:30 (UTC +01:00)
View GitHub Profile
@parimooa
parimooa / test_param.py
Last active December 9, 2019 20:36
How to order parameters in parameterize tests in pytest
import pytest
scenarios = [('first', {'attribute': 'value'}), ('second', {'attribute': 'value'})]
@pytest.mark.parametrize("test_id,scenario",scenarios)
@pytest.mark.parametrize("count",range(3)) #Remember the order , if you move it first then it will not run it the order i desired i-e first,second,first second
def test_scenarios(test_id,scenario,count):
assert scenario["attribute"] == "value"
@parimooa
parimooa / conftest.py
Created December 8, 2019 20:16
How to reuse ssh connection during entire pytest suite
import pytest
@pytest.fixture(scope="module")
def run_remote_fixture_script(connection_info, command_name, *args):
ssh = SSHClient()
ssh.connect(...)
command = '''
./load_fixture_script {test_target} {command} {args};
'''.format(
test_target=connection_info.target,
command=command_name,