Example #1
0
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Vispy Development Team.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
from os import path as op
import os

from vispy.util import config, sys_info, _TempDir, set_data_dir, save_config, load_data_file
from vispy.testing import assert_in, requires_application, run_tests_if_main, assert_raises, assert_equal, assert_true

temp_dir = _TempDir()


@requires_application()
def test_sys_info():
    """Test printing of system information"""
    fname = op.join(temp_dir, "info.txt")
    sys_info(fname)
    assert_raises(IOError, sys_info, fname)  # no overwrite
    with open(fname, "r") as fid:
        out = "".join(fid.readlines())
    keys = ["GL version", "Python", "Backend", "pyglet", "Platform:"]
    for key in keys:
        assert_in(key, out)
    print(out)
    assert_true("Info-gathering error" not in out)


def test_config():
    """Test vispy config methods and file downloading"""
    assert_raises(TypeError, config.update, data_path=dict())
    assert_raises(KeyError, config.update, foo="bar")  # bad key
Example #2
0
# -*- coding: utf-8 -*-
# Copyright (c) 2014, Vispy Development Team.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
import numpy as np
from os import path as op
from numpy.testing import assert_allclose, assert_array_equal

from vispy.io import write_mesh, read_mesh, load_data_file
from vispy.geometry import _fast_cross_3d
from vispy.util import _TempDir
from vispy.testing import run_tests_if_main, assert_equal, assert_raises

temp_dir = _TempDir()


def test_wavefront():
    """Test wavefront reader"""
    fname_mesh = load_data_file('orig/triceratops.obj.gz')
    fname_out = op.join(temp_dir, 'temp.obj')
    mesh1 = read_mesh(fname_mesh)
    assert_raises(IOError, read_mesh, 'foo.obj')
    assert_raises(ValueError, read_mesh, op.abspath(__file__))
    assert_raises(ValueError, write_mesh, fname_out, *mesh1, format='foo')
    write_mesh(fname_out, mesh1[0], mesh1[1], mesh1[2], mesh1[3])
    assert_raises(IOError, write_mesh, fname_out, *mesh1)
    write_mesh(fname_out, *mesh1, overwrite=True)
    mesh2 = read_mesh(fname_out)
    assert_equal(len(mesh1), len(mesh2))
    for m1, m2 in zip(mesh1, mesh2):
        if m1 is None:
            assert_equal(m2, None)