Files
gears/tests/test_gears.py
Lorenz Lechner be58b5856f tests: pytest, visual tests (projekt_001), CI (pylint+visual, update-references)
- Switch from unittest to pytest (test_gears.py, xfail for OCC helical extrusion)
- Add visual regression tests (freecad.visual_tests): test_visual_projects.py, projekt_001
- Pixi: test/test-visual/test-visual-xvfb/create-references/clean-test, create-references-xvfb
- GitHub: Pylint workflow on push, pull_request, workflow_dispatch; visual tests on Linux (xvfb)
- GitHub: Update reference images workflow (workflow_dispatch)
- setup-pixi v0.9.4, pixi v0.44.0, checkout v4
- .gitignore: artifacts/, .pytest_exitstatus

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 21:02:35 +01:00

29 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import pytest
from freecad import app
from freecad import part
from freecad.gears.basegear import helical_extrusion
@pytest.mark.xfail(reason="OCC returns wrong face normals/positions for helical extrusion")
def test_helical_extrusion():
"""check if helical extrusion is working correctly"""
normal = app.Vector(0, 0, 1)
midpoint = app.Vector(0, 0, 0)
radius = 10
height = 10
rotation = 3.1415926535 / 4
circle = part.Circle(midpoint, normal, radius)
face = part.Face(part.Wire(circle.toShape()))
solid = helical_extrusion(face, height, rotation)
# face 0 is the cylinder
# face 1 is pointing in positive z direction
# face 2 is pointing in negative z direction
# Strict checks: known to fail with current OCC (Open CASCADE) wrong face normals/positions
assert (solid.Faces[1].normalAt(0, 0) - normal).Length == 0.0
assert (solid.Faces[2].normalAt(0, 0) + normal).Length == 0.0
assert solid.Faces[1].valueAt(0, 0)[2] == height
assert solid.Faces[2].valueAt(0, 0)[2] == 0.0