picogl.tests.test_vertex_base

Unit tests for the VertexBase class in the ElMo OpenGL backend.

This module contains a suite of unit tests for verifying the correctness, robustness, and interface of the picogl.buffers.base.VertexBase class, which serves as a base for OpenGL vertex buffer objects (VBOs).

The tests cover:

  • Object initialization with handle parameter.

  • Available methods: bind, unbind, delete, set_layout, attach_buffers.

  • Context management (enter/exit).

  • Handle management.

Dependencies:
  • unittest (standard library)

  • unittest.mock.MagicMock for method mocking

  • picogl.buffers.base.VertexBase

To run the tests:

python -m unittest path.to.this.module

Classes

TestVertexBase

A class whose instances are single test cases.

Module Contents

class picogl.tests.test_vertex_base.TestVertexBase(methodName='runTest')[source]

Bases: unittest.TestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

setUp()[source]

Set up test fixtures.

test_initialization()[source]

Test that the VertexBase initializes correctly.

test_handle_attribute()[source]

Test that the handle attribute is accessible.

test_available_methods()[source]

Test that all expected methods exist.

test_bind_method()[source]

Test that the bind method exists and is callable.

test_unbind_method()[source]

Test that the unbind method exists and is callable.

test_delete_method()[source]

Test that the delete method exists and is callable.

test_set_layout_method()[source]

Test that the set_layout method exists and is callable.

test_attach_buffers_method()[source]

Test that the attach_buffers method exists and is callable.

test_context_manager()[source]

Test that VertexBase can be used as a context manager.

test_enter_exit_methods()[source]

Test that __enter__ and __exit__ methods are callable.

test_method_signatures()[source]

Test that methods have the expected signatures.

test_handle_none_initialization()[source]

Test initialization with handle=None.

test_handle_reassignment()[source]

Test that handle can be reassigned.

test_instance_attributes()[source]

Test that instance attributes are properly set.

test_method_callability()[source]

Test that all methods are callable.

test_abstract_methods()[source]

Test that VertexBase is not abstract (no abstract methods).