File: test_moderngl_window.py

package info (click to toggle)
python-moderngl-window 3.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 69,096 kB
  • sloc: python: 12,076; makefile: 21
file content (40 lines) | stat: -rw-r--r-- 987 bytes parent folder | download
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
import sys
from unittest import TestCase, mock

import moderngl

import moderngl_window as mglw
from moderngl_window.context.base import BaseWindow


def swap_buffers(self):
    """Swap buffers closing window after 3 frames"""
    self._frames += 1
    if self._frames > 3:
        self.close()


class Config(mglw.WindowConfig):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def on_render(self, time: float, frame_time: float):
        pass


class ModernGlWindowTestCase(TestCase):

    @mock.patch('moderngl_window.context.headless.Window.swap_buffers', new=swap_buffers)
    def test_run_window_config(self):
        sys.argv = [
            'something',
            '-wnd', 'headless',
            '--size_mult', '1.0',
            '--cursor', 'False',
            '--size', '100x100',
        ]
        mglw.run_window_config(Config)

        self.assertIsInstance(mglw.window(), BaseWindow)
        self.assertIsInstance(mglw.ctx(), moderngl.Context)