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()
|