| 1 |
import pytest |
| 2 |
|
| 3 |
|
| 4 |
@pytest.fixture() |
| 5 |
def tmp_text_file(tmpdir_factory): |
| 6 |
fn = tmpdir_factory.mktemp("data").join("empty.txt") |
| 7 |
fn.write(b'') |
| 8 |
return fn |
| 9 |
|
| 10 |
|
| 11 |
@pytest.fixture |
| 12 |
def no_cover_compat(request): |
| 13 |
"""A pytest fixture to disable coverage. |
| 14 |
|
| 15 |
.. note:: |
| 16 |
|
| 17 |
After the next version of ``pytest-cov`` is released, it will be possible to directly |
| 18 |
use the ``no_cover`` fixture or marker. |
| 19 |
""" |
| 20 |
|
| 21 |
# Check with hasplugin to avoid getplugin exception in older pytest. |
| 22 |
if request.config.pluginmanager.hasplugin('_cov'): |
| 23 |
plugin = request.config.pluginmanager.getplugin('_cov') |
| 24 |
if plugin.cov_controller: |
| 25 |
plugin.cov_controller.cov.stop() |
| 26 |
plugin.cov_controller.unset_env() |
| 27 |
yield plugin.cov_controller |
| 28 |
plugin.cov_controller.set_env() |
| 29 |
plugin.cov_controller.cov.start() |