build123d/tests/test_direct_api/test_jupyter.py
2025-01-22 15:23:56 -05:00

57 lines
1.4 KiB
Python

"""
build123d imports
name: test_jupyter.py
by: Gumyr
date: January 22, 2025
desc:
This python module contains tests for the build123d project.
license:
Copyright 2025 Gumyr
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import unittest
from build123d.geometry import Vector
from build123d.jupyter_tools import to_vtkpoly_string, display
from build123d.topology import Solid
class TestJupyter(unittest.TestCase):
def test_repr_javascript(self):
shape = Solid.make_box(1, 1, 1)
# Test no exception on rendering to js
js1 = shape._repr_javascript_()
assert "function render" in js1
def test_display_error(self):
with self.assertRaises(AttributeError):
display(Vector())
with self.assertRaises(ValueError):
to_vtkpoly_string("invalid")
with self.assertRaises(ValueError):
display("invalid")
if __name__ == "__main__":
unittest.main()