[TIP] pytest from Python code

Dietrich Balima DBalima at slb.com
Mon Jul 2 05:47:32 PDT 2012


Hi,
I have 2 questions about pytest, I want put result files in a directory by calling pytest from python code directly.
I have seen there is pytest.main() to do this, but I don't know how.
This is what I have.
Test file is here : c:\tests\class_a\mytest.py
I want put the result files(xml) here : c:\tests\class_a\test-result
Question 1 (with a class):
I have this class :
class ClassATest(object):
               def test_func1():
                              assert True

               def test_func2():
                              assert False
pytest.main("-qq", plugins=[ClassATest()],['junitxml',' c:\tests\class_a\test-result '])

Question 2 (without a class):
I have this :
def test_func1():
               assert True

def test_func2():
               assert False
pytest.main("-qq", ['junitxml',' c:\tests\class_a\test-result '])

I have do this, but it doesn't work.
How can I make it works?


Regards,
Dietrich BALIMA
Auto Test Team
Schlumberger




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20120702/0ad8d6d3/attachment.htm>


More information about the testing-in-python mailing list