File: test_helpers.py

package info (click to toggle)
python-meshio 4.3.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,464 kB
  • sloc: python: 13,177; makefile: 50
file content (46 lines) | stat: -rw-r--r-- 971 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
import sys
from pathlib import Path

import pytest

import meshio

OBJ_PATH = Path(__file__).resolve().parent / "meshes" / "obj" / "elephav.obj"


def test_read_str():
    meshio.read(str(OBJ_PATH))


def test_read_pathlike():
    meshio.read(OBJ_PATH)


def test_read_buffer():
    with open(str(OBJ_PATH)) as f:
        meshio.read(f, "obj")


@pytest.fixture
def mesh():
    return meshio.read(OBJ_PATH)


def test_write_str(mesh, tmpdir):
    tmp_path = str(tmpdir.join("tmp.obj"))
    meshio.write(tmp_path, mesh)
    assert Path(tmp_path).is_file()


@pytest.mark.skipif(sys.version_info < (3, 6), reason="Fails with 3.5")
def test_write_pathlike(mesh, tmpdir):
    tmp_path = Path(tmpdir.join("tmp.obj"))
    meshio.write(tmp_path, mesh)
    assert Path(tmp_path).is_file()


def test_write_buffer(mesh, tmpdir):
    tmp_path = str(tmpdir.join("tmp.obj"))
    with open(tmp_path, "w") as f:
        meshio.write(f, mesh, "obj")
    assert Path(tmp_path).is_file()