File: test_plotting_namespace.py

package info (click to toggle)
python-pyvista 0.46.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 176,968 kB
  • sloc: python: 94,346; sh: 216; makefile: 70
file content (40 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
from __future__ import annotations

import importlib
from pathlib import Path

import pytest

from pyvista.core.errors import PyVistaDeprecationWarning

namespace_data = Path(__file__).parent / 'namespace-plotting.txt'
with namespace_data.open() as f:
    namespace = f.read().splitlines()
    # ignore commented data
    namespace = [n.split(', ')[0] for n in namespace if not n.startswith('#')]


@pytest.mark.parametrize('name', namespace)
def test_plotting_top_namespace(name):
    module = importlib.import_module('pyvista.plotting')
    assert hasattr(module, name)


def test_common_plotting_import_paths():
    # These are `pyvista.plotting.plotting` imports found via search on GitHub
    # across multiple public repositories
    with pytest.warns(
        PyVistaDeprecationWarning,
        match='The `pyvista.plotting.plotting` module has been deprecated',
    ):
        from pyvista.plotting.plotting import _ALL_PLOTTERS  # noqa: F401
    with pytest.warns(
        PyVistaDeprecationWarning,
        match='The `pyvista.plotting.plotting` module has been deprecated',
    ):
        from pyvista.plotting.plotting import BasePlotter  # noqa: F401
    with pytest.warns(
        PyVistaDeprecationWarning,
        match='The `pyvista.plotting.plotting` module has been deprecated',
    ):
        from pyvista.plotting.plotting import Plotter  # noqa: F401