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:
168
168
169
169
.. code-block :: python
170
170
171
- pytest.main()
171
+ retcode = pytest.main()
172
172
173
173
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.
175
175
You can pass in options and arguments:
176
176
177
177
.. code-block :: python
178
178
179
- pytest.main([" -x" , " mytestdir" ])
179
+ retcode = pytest.main([" -x" , " mytestdir" ])
180
180
181
181
You can specify additional plugins to ``pytest.main ``:
182
182
@@ -191,7 +191,8 @@ You can specify additional plugins to ``pytest.main``:
191
191
print (" *** test run reporting finishing" )
192
192
193
193
194
- pytest.main([" -qq" ], plugins = [MyPlugin()])
194
+ if __name__ == " __main__" :
195
+ sys.exit(pytest.main([" -qq" ], plugins = [MyPlugin()]))
195
196
196
197
Running it will show that ``MyPlugin `` was added and its
197
198
hook was invoked:
You can’t perform that action at this time.
0 commit comments