numirias / pytest-json-report

🗒️ A pytest plugin to report test results as JSON
MIT License
147 stars 39 forks source link

README.md: Direct invocation still creates a .report.json file #54

Closed cornzyblack closed 4 years ago

cornzyblack commented 4 years ago

Direct invocation

You can also use the plugin when invoking pytest.main() directly from code:

import pytest
from pytest_jsonreport.plugin import JSONReport

plugin = JSONReport()
pytest.main(['test_foo.py'], plugins=[plugin])

The above creates a default .report.json file which may not be expected.

To prevent the default .report.json file from being created, an optional argument can be passed, as shown in the following example:

import pytest
from pytest_jsonreport.plugin import JSONReport

plugin = JSONReport()
pytest.main(['--json-report-file=none', 'test_foo.py'], plugins=[plugin])
numirias commented 4 years ago

Agree that this should be in the example, thanks!