build123d/tests
Aleksi Torhamo acbebfb017 Fix __eq__ and __ne__ for classes implementing them
Main issue, which concerns Vector, Location, and ShapeList:

Comparison with an object of a different type should not cause an
exception - they are simply not equal. Raising an exception in __eq__
can (and will*) break unrelated code that expects __eq__ to be well-behaved.

(* I noticed this bug when cq-editor choked on it while trying to find
   a name for an object in a dictionary of local variables)

There's a second more minor issue, which concerns the rest of the classes:

When the other type in __eq__ is not supported, one should technically
return NotImplemented instead of False, to allow the other type to take
part in the comparison, in case they know about our type.

(__ne__ should also not generally be implemented as just the negation of
__eq__ because of this, but that's also a moot point because the __ne__
can just be removed - Python will automatically do the right thing based
on __eq__ here)

Technically, the __eq__ for Vector and Plane is also broken in another way:
It's not transitive.

>>> a, b, c = Vector(0), Vector(9e-6), Vector(18e-6)
>>> a == b == c
True
>>> a == c
False

They should really eg. have a separate is_close() for approximate comparison,
but this isn't fixed here, since I have no idea how many places it'd break,
for one.
2024-09-22 08:07:00 +03:00
..
cyl_w_rect_hole.stl Fix import of invalid triangles Issue #472 2024-01-13 11:06:09 -05:00
svg_import_test.svg Changing import_svg to use ocpsvg 2023-10-21 11:22:11 -04:00
test_algebra.py Fixed flipped width/height Issue #565 2024-03-01 09:44:19 -05:00
test_build_common.py test_build_common.py -> fix deprecated assertAlmostEquals with assertAlmostEqual 2024-06-19 15:43:03 -05:00
test_build_enums.py Reformatted with black 24.2.0 2024-02-22 11:27:01 -05:00
test_build_generic.py Fix projection when < 1.0 apart, partial Issue #563 2024-03-01 10:57:44 -05:00
test_build_line.py test_build_line.py -> add test for vertex/start position 2024-06-24 10:19:42 -05:00
test_build_part.py Fixing Issue #475 2024-06-12 09:57:26 -04:00
test_build_sketch.py Adding apothem attribute to RegularPolygon Issue #585 2024-03-17 10:12:59 -04:00
test_direct_api.py Fix __eq__ and __ne__ for classes implementing them 2024-09-22 08:07:00 +03:00
test_drafting.py Reformatted with black 24.2.0 2024-02-22 11:27:01 -05:00
test_exporters.py Add Color to allowable types for fill_color and line_color. 2024-02-27 13:55:44 -05:00
test_exporters3d.py Removing bd_warehouse test dependency 2024-06-12 10:47:20 -04:00
test_importers.py Adding support for Windows 2024-08-21 15:41:03 -04:00
test_joints.py Add a test for revolute joints around an axis other than Z 2024-06-06 18:16:03 -07:00
test_mesher.py Color improvements: inheritance & iterable 2024-03-23 13:50:05 -04:00
test_pack.py Reformatted with black 24.2.0 2024-02-22 11:27:01 -05:00
test_persistence.py Added Compound constructor and deprecated make_compound Issue #523 2024-02-02 09:22:52 -05:00
test_topo_explore.py Adding full_round operation 2024-02-14 11:31:44 -05:00