[TIP] pytest from Python code
holger krekel
holger at merlinux.eu
Mon Jul 2 09:04:00 PDT 2012
Hi Dietrich,
On Mon, Jul 02, 2012 at 12:47 +0000, Dietrich Balima wrote:
> 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 '])
The "plugins" list is a list of instantiated plugin objects. You don't
need this argument at all, i think.
You rather should create a file with your test code in it and then
run:
pytest.main(["--junitxml=PATH_TO_RESULT", "-qq", path_to_testfile, ])
If this doesn't work, please send the output that you get and/or a full
example.
best,
holger
> 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
>
>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
More information about the testing-in-python
mailing list