File: test_vispy.py

package info (click to toggle)
python-vispy 0.15.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,868 kB
  • sloc: python: 59,799; javascript: 6,800; makefile: 69; sh: 6
file content (48 lines) | stat: -rw-r--r-- 1,494 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
"""Tests to ensure that base vispy namespace functions correctly,
including configuration options.
"""

import vispy.app
from vispy.testing import (requires_application, run_tests_if_main,
                           assert_raises, assert_equal, assert_not_equal)


@requires_application('pyside')
def test_use():

    # Set default app to None, so we can test the use function
    vispy.app.use_app()
    default_app = vispy.app._default_app.default_app
    vispy.app._default_app.default_app = None

    app_name = default_app.backend_name.split(' ')[0]

    try:
        # With no arguments, should do nothing
        assert_raises(TypeError, vispy.use)
        assert_equal(vispy.app._default_app.default_app, None)

        # With only gl args, should do nothing to app
        vispy.use(gl='gl2')
        assert_equal(vispy.app._default_app.default_app, None)

        # Specify app (one we know works)
        vispy.use(app_name)
        assert_not_equal(vispy.app._default_app.default_app, None)

        # Again, but now wrong app
        wrong_name = 'glfw' if app_name.lower() != 'glfw' else 'pyqt4'
        assert_raises(RuntimeError, vispy.use, wrong_name)

        # And both
        vispy.use(app_name, 'gl2')

    finally:
        # Restore
        vispy.app._default_app.default_app = default_app


run_tests_if_main()