Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding smoke test for fig
  • Loading branch information
adam-urbanczyk committed Jun 12, 2025
commit dd7803e479d2f84b5e97ea3743048ecdd1be57cc
22 changes: 22 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest


def pytest_addoption(parser):
parser.addoption("--gui", action="store_true", default=False, help="run gui tests")


def pytest_configure(config):
config.addinivalue_line("markers", "gui: mark gui test")


def pytest_collection_modifyitems(config, items):

# run gui tests --gui option is proveded
if config.getoption("--gui"):
return

# skip gui tests otherwise
skip_gui = pytest.mark.skip(reason="need --gui option to run")
for item in items:
if "gui" in item.keywords:
item.add_marker(skip_gui)
44 changes: 44 additions & 0 deletions tests/test_fig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from cadquery import Workplane, Assembly, Sketch, Vector, Location
from cadquery.func import box
from cadquery.vis import vtkAxesActor, ctrlPts
from cadquery.fig import Figure

from pytest import fixture, mark


@fixture(scope="module")
def fig():
return Figure()


@mark.gui
def test_fig(fig):

# showables
s = box(1, 1, 1)
wp = Workplane().box(1, 1, 1)
assy = Assembly().add(box(1, 1, 1))
sk = Sketch().rect(1, 1)
ctrl_pts = ctrlPts(sk.val().toNURBS())
v = Vector()
loc = Location()
act = vtkAxesActor()

# individual showables
fig.show(s, wp, assy, sk, ctrl_pts, v, loc, act)

# fit
fig.fit()

# clear
fig.clear()

# lists of showables
fig.show(s.Edges()).show([Vector(), Vector(0, 1)])

# displaying nonsense does not throw
fig.show("a").show(["a", 1234])

# pop
fig.show(s, color="red")
fig.pop()