I want to test some scenarios by executing command through ssh connection.So need the ssh connection fixture to be called second time.
So my scenario is like:
@pytest.fixture(scope=”session”)
def get_ssh_connection(vars, logger):
ssh = SshClient(ip=vars["ip"],
port=vars["port"],
user=vars["username"],
passwd=vars["pw"])
ssh.connect()
yield ssh
ssh.close()
Inside test script:
@pytest.fixture(scope="class", autouse=True)
def setup_teardown(self, list):
self.ssh.exec_cmd(f"mv {file} {newfile}") # rename file
self.restartDevice() #ssh connection closed
yield
**self.ssh.exec_cmd(f"mv {newfile} {file}")** #restore file
self.restartDevice()
How to enable this ssh connection (highlighted one) after restartdevice since ssh connection is a fixture as session.
Please suggest, Thanks in advance.