Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions tests/test_packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ def test_cross_library_transitive_dep(self, tmp_path):
"module scaled_box(s) { cube(scale_val(s)); }")
entry = write(tmp_path, "entry.scad",
"use <shapes.scad>\nscaled_box(5);")
# Note: use <math.scad> inside shapes.scad is processed with process_includes=True,
# so scale_val ends up in the pool via shapes.scad's flattened parse
# shapes.scad itself references math.scad, and packing resolves that dependency
# when processing the library, so scaled_box can be emitted correctly.
result = pack(entry)
assert "scaled_box" in result

Expand Down Expand Up @@ -373,7 +373,7 @@ def test_escaped_quote_inside_string_preserved(self):

def test_unterminated_string_at_eof_handled(self):
# A string literal that reaches EOF without a closing `"` must not crash —
# exercises the `while i < len(code)` exit-without-break branch (58->68).
# exercises the string-scanning loop path where EOF is reached before a closing quote.
result = _strip_expression_comments('"unclosed')
assert '"unclosed' in result

Expand Down Expand Up @@ -459,8 +459,8 @@ def test_fallback_warning_when_string_parse_fails(self, tmp_path, capsys, monkey
assert "warning" in captured.err.lower()

def test_fallback_no_warning_for_empty_file(self, tmp_path, capsys, monkeypatch):
# When getASTfromString fails AND the file is empty, the fallback also returns
# nothing — `if nodes:` is False so no warning is printed (branch 239->245).
# When getASTfromString fails and the file is empty, the fallback returns
# no nodes, so `if nodes:` is False and no warning is printed.
entry = write(tmp_path, "entry.scad", "")
monkeypatch.setattr("openscad_packer.packer.getASTfromString", lambda *a, **kw: None)
result = Packer(str(entry), []).pack()
Expand Down
2 changes: 0 additions & 2 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Unit tests for openscad_packer.resolver."""
from pathlib import Path

import pytest

from openscad_packer.resolver import resolve_library


Expand Down
3 changes: 1 addition & 2 deletions tests/test_shaker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Unit tests for openscad_packer.shaker."""
from pathlib import Path

import pytest
from openscad_parser.ast import getASTfromFile
from openscad_parser.ast.nodes import FunctionDeclaration, ModuleDeclaration

Expand All @@ -24,7 +23,7 @@ def make_pool(tmp_path: Path, content: str) -> dict:
if name not in pool:
pool[name] = []
for i, existing in enumerate(pool[name]):
if type(existing) is type(node):
if isinstance(existing, type(node)):
pool[name][i] = node
break
else:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_upstream_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ def test_three_arg_range_explicit_step_preserved(self, tmp_path):
assert "[0:1:2]" in out

def test_three_arg_range_large_step_preserved(self, tmp_path):
# [0:5:1] means start=0, step=5, end=1 — semantically different from [0:5]
# [0:5:1] means start=0, step=5, end=1 — semantically different from [0:1]
# ([0:5] is a two-arg range: start=0, end=5, implicit step=1.)
src = "x = [for (i=[0:5:1]) i];"
out = parse_and_print(tmp_path / "t.scad", src)
assert "[0:5:1]" in out
assert "[0:5]" not in out

def test_three_arg_range_negative_step_preserved(self, tmp_path):
# [10:0:-1] means start=10, step=0, end=-1 in internal storage
# [10:-1:0] means start=10, step=-1, end=0 in internal storage
src = "x = [for (i=[10:-1:0]) i];"
out = parse_and_print(tmp_path / "t.scad", src)
assert "[10:-1:0]" in out
Expand Down
Loading