I have two tests created with pytest: Test1 and Test2. I would like to create method which would start whose two tests. I know that i can do it with cmd, but i prefer py file. In unittest there are testloader and testsuite methods:
t1 = unittest.TestLoader().loadTestsFromTestCase(Test1)
t2 = unittest.TestLoader().loadTestsFromTestCase(Test2)
test_suite = unittest.TestSuite([t1, t2])
unittest.TextTestRunner(verbosity=2).run(test_suite)
I need same thing, but for py test
You can use pytest.main()
at the end of the test file. You can also pass arguments as list: `pytest.main(['-x', 'mytestdir']).
Documentation: https://docs.pytest.org/en/latest/usage.html#calling-pytest-from-python-code