File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -168,15 +168,15 @@ You can invoke ``pytest`` from Python code directly:
168168
169169.. code-block :: python
170170
171- pytest.main()
171+ retcode = pytest.main()
172172
173173 this acts as if you would call "pytest" from the command line.
174- It will not raise `` SystemExit `` but return the exitcode instead.
174+ It will not raise :class: ` SystemExit ` but return the :ref: ` exit code < exit-codes >` instead.
175175You can pass in options and arguments:
176176
177177.. code-block :: python
178178
179- pytest.main([" -x" , " mytestdir" ])
179+ retcode = pytest.main([" -x" , " mytestdir" ])
180180
181181 You can specify additional plugins to ``pytest.main ``:
182182
@@ -191,7 +191,8 @@ You can specify additional plugins to ``pytest.main``:
191191 print (" *** test run reporting finishing" )
192192
193193
194- pytest.main([" -qq" ], plugins = [MyPlugin()])
194+ if __name__ == " __main__" :
195+ sys.exit(pytest.main([" -qq" ], plugins = [MyPlugin()]))
195196
196197 Running it will show that ``MyPlugin `` was added and its
197198hook was invoked:
You can’t perform that action at this time.
0 commit comments