File: conftest.py

package info (click to toggle)
python-wordcloud 1.8.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 328 kB
  • sloc: python: 2,790; sh: 40; makefile: 9
file content (29 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pytest


@pytest.fixture()
def tmp_text_file(tmpdir_factory):
    fn = tmpdir_factory.mktemp("data").join("empty.txt")
    fn.write(b'')
    return fn


@pytest.fixture
def no_cover_compat(request):
    """A pytest fixture to disable coverage.

    .. note::

         After the next version of ``pytest-cov`` is released, it will be possible to directly
         use the ``no_cover`` fixture or marker.
    """

    # Check with hasplugin to avoid getplugin exception in older pytest.
    if request.config.pluginmanager.hasplugin('_cov'):
        plugin = request.config.pluginmanager.getplugin('_cov')
        if plugin.cov_controller:
            plugin.cov_controller.cov.stop()
            plugin.cov_controller.unset_env()
            yield plugin.cov_controller
            plugin.cov_controller.set_env()
            plugin.cov_controller.cov.start()