You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can easily instruct ``pytest`` to discover tests from every python file::
183
+
.. regendoc:wipe
184
184
185
+
You can easily instruct ``pytest`` to discover tests from every Python file::
185
186
186
187
# content of pytest.ini
187
188
[pytest]
188
189
python_files = *.py
189
190
190
-
However, many projects will have a ``setup.py`` which they don't want to be imported. Moreover, there may files only importable by a specific python version.
191
-
For such cases you can dynamically define files to be ignored by listing
192
-
them in a ``conftest.py`` file::
191
+
However, many projects will have a ``setup.py`` which they don't want to be
192
+
imported. Moreover, there may files only importable by a specific python
193
+
version. For such cases you can dynamically define files to be ignored by
194
+
listing them in a ``conftest.py`` file::
193
195
194
196
# content of conftest.py
195
197
import sys
@@ -198,7 +200,7 @@ them in a ``conftest.py`` file::
198
200
if sys.version_info[0] > 2:
199
201
collect_ignore.append("pkg/module_py2.py")
200
202
201
-
And then if you have a module file like this::
203
+
and then if you have a module file like this::
202
204
203
205
# content of pkg/module_py2.py
204
206
def test_only_on_python2():
@@ -207,13 +209,13 @@ And then if you have a module file like this::
207
209
except Exception, e:
208
210
pass
209
211
210
-
and a setup.py dummy file like this::
212
+
and a ``setup.py`` dummy file like this::
211
213
212
214
# content of setup.py
213
215
0/0 # will raise exception if imported
214
216
215
-
then a pytest run on Python2 will find the one test and will leave out the
216
-
setup.py file::
217
+
If you run with a Python 2 interpreter then you will find the one test and will
218
+
leave out the ``setup.py`` file::
217
219
218
220
#$ pytest --collect-only
219
221
====== test session starts ======
@@ -225,13 +227,13 @@ setup.py file::
225
227
226
228
====== no tests ran in 0.04 seconds ======
227
229
228
-
If you run with a Python3 interpreter both the one test and the setup.py file
229
-
will be left out::
230
+
If you run with a Python 3 interpreter both the one test and the ``setup.py``
231
+
file will be left out::
230
232
231
233
$ pytest --collect-only
232
234
======= test session starts ========
233
235
platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y
0 commit comments