@ -48,6 +48,15 @@ class Capsule(unittest.TestCase):
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertEqual ( a . attribute_count ( ) , 1 )
self . assertEqual ( a . attribute_count ( ) , 1 )
def test_2d_wireframe_invalid ( self ) :
# This is fine
primitives . capsule2d_wireframe ( 1 , 1 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring and one cylinder ring but got 0 and 1 " ) :
primitives . capsule2d_wireframe ( 0 , 1 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring and one cylinder ring but got 1 and 0 " ) :
primitives . capsule2d_wireframe ( 1 , 0 , 1.0 )
def test_3d_solid ( self ) :
def test_3d_solid ( self ) :
a = primitives . capsule3d_solid ( 3 , 3 , 10 , 2.0 , primitives . CapsuleFlags . TEXTURE_COORDINATES | primitives . CapsuleFlags . TANGENTS )
a = primitives . capsule3d_solid ( 3 , 3 , 10 , 2.0 , primitives . CapsuleFlags . TEXTURE_COORDINATES | primitives . CapsuleFlags . TANGENTS )
self . assertEqual ( a . primitive , MeshPrimitive . TRIANGLES )
self . assertEqual ( a . primitive , MeshPrimitive . TRIANGLES )
@ -59,11 +68,36 @@ class Capsule(unittest.TestCase):
self . assertTrue ( b . is_indexed )
self . assertTrue ( b . is_indexed )
self . assertEqual ( b . attribute_count ( ) , 2 )
self . assertEqual ( b . attribute_count ( ) , 2 )
def test_3d_solid_invalid ( self ) :
# This is fine
primitives . capsule3d_solid ( 1 , 1 , 3 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring, one cylinder ring and three segments but got 0, 1 and 3 " ) :
primitives . capsule3d_solid ( 0 , 1 , 3 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring, one cylinder ring and three segments but got 1, 0 and 3 " ) :
primitives . capsule3d_solid ( 1 , 0 , 3 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring, one cylinder ring and three segments but got 1, 1 and 2 " ) :
primitives . capsule3d_solid ( 1 , 1 , 2 , 1.0 )
def test_3d_wireframe ( self ) :
def test_3d_wireframe ( self ) :
a = primitives . capsule3d_wireframe ( 5 , 3 , 12 , 0.3 )
a = primitives . capsule3d_wireframe ( 5 , 3 , 12 , 0.3 )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertTrue ( a . is_indexed )
self . assertTrue ( a . is_indexed )
def test_3d_wireframe_invalid ( self ) :
# This is fine
primitives . capsule3d_wireframe ( 1 , 1 , 4 , 1.0 )
primitives . capsule3d_wireframe ( 1 , 1 , 16 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring, one cylinder ring and multiples of 4 segments but got 0, 1 and 4 " ) :
primitives . capsule3d_wireframe ( 0 , 1 , 4 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring, one cylinder ring and multiples of 4 segments but got 1, 0 and 4 " ) :
primitives . capsule3d_wireframe ( 1 , 0 , 4 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring, one cylinder ring and multiples of 4 segments but got 1, 1 and 9 " ) :
primitives . capsule3d_wireframe ( 1 , 1 , 9 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one hemisphere ring, one cylinder ring and multiples of 4 segments but got 1, 1 and 0 " ) :
primitives . capsule3d_wireframe ( 1 , 1 , 0 , 1.0 )
class Circle ( unittest . TestCase ) :
class Circle ( unittest . TestCase ) :
def test_2d_solid ( self ) :
def test_2d_solid ( self ) :
a = primitives . circle2d_solid ( 5 , primitives . Circle2DFlags . TEXTURE_COORDINATES )
a = primitives . circle2d_solid ( 5 , primitives . Circle2DFlags . TEXTURE_COORDINATES )
@ -76,11 +110,25 @@ class Circle(unittest.TestCase):
self . assertFalse ( b . is_indexed )
self . assertFalse ( b . is_indexed )
self . assertEqual ( b . attribute_count ( ) , 1 )
self . assertEqual ( b . attribute_count ( ) , 1 )
def test_2d_solid_invalid ( self ) :
# This is fine
primitives . circle2d_solid ( 3 )
with self . assertRaisesRegex ( AssertionError , " expected at least three segments but got 2 " ) :
primitives . circle2d_solid ( 2 )
def test_2d_wireframe ( self ) :
def test_2d_wireframe ( self ) :
a = primitives . circle2d_wireframe ( 5 )
a = primitives . circle2d_wireframe ( 5 )
self . assertEqual ( a . primitive , MeshPrimitive . LINE_LOOP )
self . assertEqual ( a . primitive , MeshPrimitive . LINE_LOOP )
self . assertFalse ( a . is_indexed )
self . assertFalse ( a . is_indexed )
def test_2d_wireframe_invalid ( self ) :
# This is fine
primitives . circle2d_wireframe ( 3 )
with self . assertRaisesRegex ( AssertionError , " expected at least three segments but got 2 " ) :
primitives . circle2d_wireframe ( 2 )
def test_3d_solid ( self ) :
def test_3d_solid ( self ) :
a = primitives . circle3d_solid ( 5 , primitives . Circle3DFlags . TEXTURE_COORDINATES | primitives . Circle3DFlags . TANGENTS )
a = primitives . circle3d_solid ( 5 , primitives . Circle3DFlags . TEXTURE_COORDINATES | primitives . Circle3DFlags . TANGENTS )
self . assertEqual ( a . primitive , MeshPrimitive . TRIANGLE_FAN )
self . assertEqual ( a . primitive , MeshPrimitive . TRIANGLE_FAN )
@ -92,11 +140,25 @@ class Circle(unittest.TestCase):
self . assertFalse ( b . is_indexed )
self . assertFalse ( b . is_indexed )
self . assertEqual ( b . attribute_count ( ) , 2 )
self . assertEqual ( b . attribute_count ( ) , 2 )
def test_3d_solid_invalid ( self ) :
# This is fine
primitives . circle3d_solid ( 3 )
with self . assertRaisesRegex ( AssertionError , " expected at least three segments but got 2 " ) :
primitives . circle3d_solid ( 2 )
def test_3d_wireframe ( self ) :
def test_3d_wireframe ( self ) :
a = primitives . circle3d_wireframe ( 5 )
a = primitives . circle3d_wireframe ( 5 )
self . assertEqual ( a . primitive , MeshPrimitive . LINE_LOOP )
self . assertEqual ( a . primitive , MeshPrimitive . LINE_LOOP )
self . assertFalse ( a . is_indexed )
self . assertFalse ( a . is_indexed )
def test_3d_wireframe_invalid ( self ) :
# This is fine
primitives . circle3d_wireframe ( 3 )
with self . assertRaisesRegex ( AssertionError , " expected at least three segments but got 2 " ) :
primitives . circle3d_wireframe ( 2 )
class Cone ( unittest . TestCase ) :
class Cone ( unittest . TestCase ) :
def test_solid ( self ) :
def test_solid ( self ) :
a = primitives . cone_solid ( 5 , 7 , 7.1 , primitives . ConeFlags . TEXTURE_COORDINATES | primitives . ConeFlags . CAP_END )
a = primitives . cone_solid ( 5 , 7 , 7.1 , primitives . ConeFlags . TEXTURE_COORDINATES | primitives . ConeFlags . CAP_END )
@ -109,11 +171,30 @@ class Cone(unittest.TestCase):
self . assertTrue ( b . is_indexed )
self . assertTrue ( b . is_indexed )
self . assertEqual ( b . attribute_count ( ) , 2 )
self . assertEqual ( b . attribute_count ( ) , 2 )
def test_solid_invalid ( self ) :
# This is fine
primitives . cone_solid ( 1 , 3 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one ring and three segments but got 0 and 3 " ) :
primitives . cone_solid ( 0 , 3 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one ring and three segments but got 1 and 2 " ) :
primitives . cone_solid ( 1 , 2 , 1.0 )
def test_wireframe ( self ) :
def test_wireframe ( self ) :
a = primitives . cone_wireframe ( 16 , 7.1 )
a = primitives . cone_wireframe ( 16 , 7.1 )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertTrue ( a . is_indexed )
self . assertTrue ( a . is_indexed )
def test_wireframe_invalid ( self ) :
# This is fine
primitives . cone_wireframe ( 4 , 1.0 )
primitives . cone_wireframe ( 16 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected multiples of 4 segments but got 9 " ) :
primitives . cone_wireframe ( 9 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected multiples of 4 segments but got 0 " ) :
primitives . cone_wireframe ( 0 , 1.0 )
class Crosshair ( unittest . TestCase ) :
class Crosshair ( unittest . TestCase ) :
def test_2d ( self ) :
def test_2d ( self ) :
a = primitives . crosshair2d ( )
a = primitives . crosshair2d ( )
@ -153,11 +234,32 @@ class Cylinder(unittest.TestCase):
self . assertTrue ( b . is_indexed )
self . assertTrue ( b . is_indexed )
self . assertEqual ( b . attribute_count ( ) , 2 )
self . assertEqual ( b . attribute_count ( ) , 2 )
def test_solid_invalid ( self ) :
# This is fine
primitives . cylinder_solid ( 1 , 3 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one ring and three segments but got 0 and 3 " ) :
primitives . cylinder_solid ( 0 , 3 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one ring and three segments but got 1 and 2 " ) :
primitives . cylinder_solid ( 1 , 2 , 1.0 )
def test_wireframe ( self ) :
def test_wireframe ( self ) :
a = primitives . cylinder_wireframe ( 8 , 16 , 1.1 )
a = primitives . cylinder_wireframe ( 8 , 16 , 1.1 )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertTrue ( a . is_indexed )
self . assertTrue ( a . is_indexed )
def test_wireframe_invalid ( self ) :
# This is fine
primitives . cylinder_wireframe ( 1 , 4 , 1.0 )
primitives . cylinder_wireframe ( 1 , 16 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one ring and multiples of 4 segments but got 0 and 4 " ) :
primitives . cylinder_wireframe ( 0 , 4 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one ring and multiples of 4 segments but got 1 and 9 " ) :
primitives . cylinder_wireframe ( 1 , 9 , 1.0 )
with self . assertRaisesRegex ( AssertionError , " expected at least one ring and multiples of 4 segments but got 1 and 0 " ) :
primitives . cylinder_wireframe ( 1 , 0 , 1.0 )
class Gradient ( unittest . TestCase ) :
class Gradient ( unittest . TestCase ) :
def test_gradient2d ( self ) :
def test_gradient2d ( self ) :
a = primitives . gradient2d ( ( 3.1 , 2.0 ) , Color3 ( ) , ( 0.2 , 1.1 ) , Color4 ( ) )
a = primitives . gradient2d ( ( 3.1 , 2.0 ) , Color3 ( ) , ( 0.2 , 1.1 ) , Color4 ( ) )
@ -280,7 +382,30 @@ class UVSphere(unittest.TestCase):
self . assertTrue ( b . is_indexed )
self . assertTrue ( b . is_indexed )
self . assertEqual ( b . attribute_count ( ) , 2 )
self . assertEqual ( b . attribute_count ( ) , 2 )
def test_solid_invalid ( self ) :
# This is fine
primitives . uv_sphere_solid ( 2 , 3 )
with self . assertRaisesRegex ( AssertionError , " expected at least two rings and three segments but got 1 and 3 " ) :
primitives . uv_sphere_solid ( 1 , 3 )
with self . assertRaisesRegex ( AssertionError , " expected at least two rings and three segments but got 2 and 2 " ) :
primitives . uv_sphere_solid ( 2 , 2 )
def test_wireframe ( self ) :
def test_wireframe ( self ) :
a = primitives . uv_sphere_wireframe ( 6 , 8 )
a = primitives . uv_sphere_wireframe ( 6 , 8 )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertEqual ( a . primitive , MeshPrimitive . LINES )
self . assertTrue ( a . is_indexed )
self . assertTrue ( a . is_indexed )
def test_wireframe_invalid ( self ) :
# This is fine
primitives . uv_sphere_wireframe ( 2 , 4 )
primitives . uv_sphere_wireframe ( 4 , 16 )
with self . assertRaisesRegex ( AssertionError , " expected multiples of 2 rings and multiples of 4 segments but got 3 and 4 " ) :
primitives . uv_sphere_wireframe ( 3 , 4 )
with self . assertRaisesRegex ( AssertionError , " expected multiples of 2 rings and multiples of 4 segments but got 0 and 4 " ) :
primitives . uv_sphere_wireframe ( 0 , 4 )
with self . assertRaisesRegex ( AssertionError , " expected multiples of 2 rings and multiples of 4 segments but got 2 and 9 " ) :
primitives . uv_sphere_wireframe ( 2 , 9 )
with self . assertRaisesRegex ( AssertionError , " expected multiples of 2 rings and multiples of 4 segments but got 2 and 0 " ) :
primitives . uv_sphere_wireframe ( 2 , 0 )