Issue
I have console-menu, like:
if n == 1:
exec('pytest test_1.py' ) # example, it doesn't work
elif n == 2:
exec('pytest test_2.py' ) # example, it doesn't work
and login.py:
from functools import partial
import pytest_bdd
scenario = partial(pytest_bdd.scenario, '..\\login.feature')
@Scenario('login 2')
def test_2():
pass()
and I want to start pytest for special methods (test_2), when I use this menu. Now I runnig my pytest from PyCharm terminal or "run""debug".
How can I use exec() from python for call pytest?
Like:
exec('pytest -s login.test_2')
Is it possible? Or maybe it has another way?
Solution
I think you can call pytest using subprocess:
import subprocess
subprocess.run(["pytest", "-s", "login.test_2"])
Answered By - Daniel Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.