File: test_labels.py

package info (click to toggle)
python-moderngl 5.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,700 kB
  • sloc: python: 15,758; cpp: 14,665; makefile: 14
file content (32 lines) | stat: -rw-r--r-- 663 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
import moderngl
import pytest

def test_error_when_label_is_too_long(ctx):
    buf = ctx.buffer(reserve=1024)
    max_label_length = ctx.max_label_length

    with pytest.raises(moderngl.Error):
        buf.label = "F" * (max_label_length + 1)


def test_error_with_wrong_type(ctx):
    buf = ctx.buffer(reserve=1024)

    with pytest.raises(TypeError):
        buf.label = 123


def test_no_label_on_creation(ctx):
    buf = ctx.buffer(reserve=1024)

    assert buf.label is None


def test_clearing_label(ctx):
    buf = ctx.buffer(reserve=1024)
    buf.label = "test buffer"
    assert buf.label is not None

    buf.label = None

    assert buf.label is None