def after_class_creation(cls):
     r"""Actions to be taken during class construction."""
     parent.TestJSONObjectMetaschemaType.after_class_creation(cls)
     cls._value = _test_value
     cls._fulldef = {'type': cls.get_import_cls().name}
     cls._typedef = {'type': cls._fulldef['type']}
     cls._valid_encoded = [cls._fulldef]
     cls._valid_decoded = [
         cls._value,
         PlyMetaschemaType.PlyDict(**_test_value), {
             'vertices': [],
             'faces': [],
             'alt_verts': copy.deepcopy(_test_value['vertices'])
         }, _test_value_int64
     ]
     if PlyMetaschemaType.trimesh:
         cls._valid_decoded.append(
             PlyMetaschemaType.PlyDict(**_test_value).as_trimesh())
     cls._invalid_encoded = [{}]
     cls._invalid_decoded = [{
         'vertices': [{k: 0.0
                       for k in 'xyz'}],
         'faces': [{
             'vertex_index': [0, 1, 2]
         }]
     }]
     cls._compatible_objects = [(cls._value, cls._value, None)]
     cls._encode_data_kwargs = {'comments': ['Test comment']}
예제 #2
0
def test_singular2plural():
    r"""Test conversion from singular element names to plural ones and back."""
    pairs = [('face', 'faces'), ('vertex', 'vertices'),
             ('vertex_index', 'vertex_indices')]
    for s, p in pairs:
        assert_equal(PlyMetaschemaType.singular2plural(s), p)
        assert_equal(PlyMetaschemaType.plural2singular(p), s)
    assert_raises(ValueError, PlyMetaschemaType.plural2singular, 'invalid')
예제 #3
0
def test_singular2plural():
    r"""Test conversion from singular element names to plural ones and back."""
    pairs = [('face', 'faces'), ('vertex', 'vertices'),
             ('vertex_index', 'vertex_indices')]
    for s, p in pairs:
        assert(PlyMetaschemaType.singular2plural(s) == p)
        assert(PlyMetaschemaType.plural2singular(p) == s)
    with pytest.raises(ValueError):
        PlyMetaschemaType.plural2singular('invalid')
예제 #4
0
 def valid_decoded(self, value, ply_test_value, ply_test_value_int64):
     r"""list: Objects that are valid under this type."""
     out = [value,
            PlyMetaschemaType.PlyDict(**ply_test_value),
            {'vertices': [], 'faces': [],
             'alt_verts': copy.deepcopy(ply_test_value['vertices'])},
            ply_test_value_int64]
     if PlyMetaschemaType.trimesh:
         out.append(PlyMetaschemaType.PlyDict(**ply_test_value).as_trimesh())
     return out
예제 #5
0
def test_create_schema():
    r"""Test create_schema."""
    assert_raises(RuntimeError, PlyMetaschemaType.create_schema, overwrite=False)
    temp = os.path.join(tempfile.gettempdir(), 'temp_schema')
    old_schema = PlyMetaschemaType.get_schema()
    try:
        shutil.move(PlyMetaschemaType._schema_file, temp)
        new_schema = PlyMetaschemaType.get_schema()
        assert_equal(old_schema, new_schema)
    except BaseException:  # pragma: debug
        shutil.move(temp, PlyMetaschemaType._schema_file)
        raise
    shutil.move(temp, PlyMetaschemaType._schema_file)
예제 #6
0
 def __init__(self, *args, **kwargs):
     super(TestPlyMetaschemaType, self).__init__(*args, **kwargs)
     self._value = _test_value
     self._fulldef = {'type': self.import_cls.name}
     self._typedef = {'type': self.import_cls.name}
     self._valid_encoded = [self._fulldef]
     self._valid_decoded = [self._value,
                            PlyMetaschemaType.PlyDict(**_test_value),
                            {'vertices': [], 'faces': [],
                             'alt_verts': copy.deepcopy(_test_value['vertices'])},
                            _test_value_int64]
     self._invalid_encoded = [{}]
     self._invalid_decoded = [{'vertices': [{k: 0.0 for k in 'xyz'}],
                               'faces': [{'vertex_index': [0, 1, 2]}]}]
     self._compatible_objects = [(self._value, self._value, None)]
     self._encode_data_kwargs = {'comments': ['Test comment']}
예제 #7
0
def test_translate_py2ply_errors():
    r"""Test errors in translate_py2ply."""
    with pytest.raises(ValueError):
        PlyMetaschemaType.translate_py2ply('float128')
예제 #8
0
def test_translate_ply2py_errors():
    r"""Test errors in translate_ply2py."""
    with pytest.raises(ValueError):
        PlyMetaschemaType.translate_ply2py('invalid')