File: test_demos.py

package info (click to toggle)
python-pyvista 0.46.3-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 177,564 kB
  • sloc: python: 94,482; sh: 129; makefile: 70
file content (83 lines) | stat: -rw-r--r-- 1,705 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from __future__ import annotations

import platform

import numpy as np
import pytest

import pyvista as pv
from pyvista import demos
from pyvista.plotting import system_supports_plotting

skip_no_plotting = pytest.mark.skipif(
    not system_supports_plotting(),
    reason='Test requires system to support plotting',
)

# test for i386/i486/i586/i686
xfail_i386 = pytest.mark.xfail(
    platform.machine()[0]+platform.machine()[2:] == 'i86',
    reason=f"test HTTP requests are refused on {platform.machine()}"
)

@skip_no_plotting
def test_plot_glyphs():
    demos.plot_glyphs(2)


def test_atomized():
    grid = demos.logo_atomized(density=0.2, scale=0.6)
    assert grid.n_cells


def test_logo_basic():
    pd = demos.logo_basic()
    assert pd.n_cells


def test_logo_voxel():
    grid = demos.logo_voxel()
    assert grid.n_cells


@pytest.mark.skip_mac('MacOS testing on Azure fails when downloading')
@skip_no_plotting
@pytest.mark.skip_windows
@xfail_i386
def test_plot_logo():
    # simply should not fail
    demos.plot_logo()


@skip_no_plotting
def test_plot_datasets():
    # simply should not fail
    demos.plot_datasets()


def test_plot_datasets_dataset_type():
    with pytest.raises(ValueError, match='Invalid dataset_type'):
        demos.plot_datasets(dataset_type='foo')


@skip_no_plotting
def test_plot_wave():
    points = demos.plot_wave(wavetime=0.1)
    assert isinstance(points, np.ndarray)


@skip_no_plotting
def test_beam_example():
    demos.plot_beam()


@skip_no_plotting
def test_plot_ants_plane():
    demos.plot_ants_plane()


@skip_no_plotting
def test_orientation_cube():
    pl = demos.orientation_plotter()
    assert isinstance(pl, pv.Plotter)
    pl.show()