pytest_houdini.fixtures package

Submodules

pytest_houdini.fixtures.exceptions module

Exceptions raised by pytest-houdini fixtures.

exception pytest_houdini.fixtures.exceptions.MissingToolError(tool_name: str)[source]

Bases: Exception

Exception raised when a matching tool cannot be found.

Parameters:

tool_name – The missing tool name.

exception pytest_houdini.fixtures.exceptions.NoModuleTestFileError(test_file: str, extensions: tuple[str, ...])[source]

Bases: Exception

Exception raised when a module test file cannot be found.

Parameters:
  • test_file – The test file stem (no extension.)

  • extensions – The extensions which were checked.

exception pytest_houdini.fixtures.exceptions.NoTestNodeError(searched_paths: list[str])[source]

Bases: Exception

Exception raised when no test node could be found.

Parameters:

searched_paths – The test node paths which were searched.

exception pytest_houdini.fixtures.exceptions.TestNodeDoesNotContainSOPsError(node: hou.OpNode)[source]

Bases: Exception

Exception raised when a test node does not contain SOP nodes.

Parameters:

node – The node which does not contain SOP nodes.

pytest_houdini.fixtures.hip_file module

Fixtures related to hip files.

pytest_houdini.fixtures.hip_file.clear_hip_file() Generator[None][source]

Fixture to clear the current hip file before and after test running.

@pytest.mark.usefixtures("clear_hip_file")
def test_something():
    # Modify the scene state
pytest_houdini.fixtures.hip_file.clear_module_hip_file() Generator[None][source]

Fixture to clear the current hip file after running all the tests in a module.

Example

Place the following line at the top of the test module:

pytestmark = pytest.mark.usefixtures("clear_module_hip_file")
pytest_houdini.fixtures.hip_file.load_module_test_hip_file(request: pytest.FixtureRequest) Generator[None][source]

Load a test hip file with the same name as the running module.

Supports .hip, .hiplc, and .hipnc type files.

The file must be under a data/ directory which is a sibling of the test file.

The fixture will clear the hip file after the tests are completed.

Example

Place the following line at the top of the test module:

pytestmark = pytest.mark.usefixtures("load_module_test_hip_file")
pytest_houdini.fixtures.hip_file.set_test_frame() Generator[Callable][source]

Fixed to set a frame for testing, restoring the previous one after completion.

def test_func(set_test_frame):
    set_test_frame(1001)
    # Do test things

pytest_houdini.fixtures.nodes module

Fixtures related to nodes.

pytest_houdini.fixtures.nodes.create_temp_node() Generator[Callable][source]

Fixture to create a temporary node that will be destroyed on cleanup.

pytest_houdini.fixtures.nodes.obj_test_node(request: FixtureRequest) hou.OpNode[source]

Fixture to provide a node in /obj matching the test.

pytest_houdini.fixtures.nodes.obj_test_geo(obj_test_node: hou.OpNode) hou.Geometry[source]

Fixture to provide the read-only display node geometry of a node in /obj matching the test.

pytest_houdini.fixtures.nodes.obj_test_geo_copy(obj_test_geo: hou.Geometry) hou.Geometry[source]

Fixture to get a writable copy of the display node geometry of a node in /obj matching the test.

pytest_houdini.fixtures.nodes.out_test_node(request: FixtureRequest) hou.OpNode[source]

Fixture to provide a node in /out matching the test.

pytest_houdini.fixtures.other module

Other fixtures for testing.

pytest_houdini.fixtures.other.remove_abstract_methods(monkeypatch: pytest.MonkeyPatch) Callable[source]

Fixture to temporarily remove abstract methods from a class for testing purposes.

Consider the following class definition with an abstract method and a concrete method which we want to test. Rather than creating a subclass for testing any non-abstract methods we can use the fixture to remove them during the test so that the object can be instantiated.

class Foo(metaclass=abc.ABCMeta):

    @abc.abstractmethod
    def bar(self):
        pass

    def get_foo(self):
        return "foo"

def test_get_foo(remove_abstract_methods):
    remove_abstract_methods(Foo)

    f = Foo()
    assert f.get_foo() == "foo"

pytest_houdini.fixtures.shelf_tools module

Testing fixtures for shelf tools.

pytest_houdini.fixtures.shelf_tools.exec_shelf_tool_script() Callable[source]

Fixture to execute a shelf tool.

pytest_houdini.fixtures.soho module

Fixtures to support mocking Mantra/SOHO related functionality.

pytest_houdini.fixtures.soho.patch_soho(monkeypatch: pytest.MonkeyPatch, mocker: MockerFixture) NamedTuple[source]

Mock importing of mantra/soho related modules.

Available mocked modules are available via their original names from the fixture provided named tuple.

Available mocked modules:
  • IFDapi

  • IFDframe

  • IFDhooks

  • IFDsettings

  • mantra

  • soho

>>> def test_soho_thing(patch_soho):
...     patch_soho.mantra.property.return_value = 3
...     # Test code

pytest_houdini.fixtures.ui module

Fixtures to support mocking Houdini UI related functionality.

pytest_houdini.fixtures.ui.mock_hdefereval(monkeypatch: pytest.MonkeyPatch, mocker: MockerFixture) MockerFixture[source]

Mock hdefereval which isn’t available when running tests via Hython.

pytest_houdini.fixtures.ui.mock_hou_qt(monkeypatch: pytest.MonkeyPatch, mocker: MockerFixture) MockerFixture[source]

Mock the hou.qt module which isn’t available when running tests via Hython.

pytest_houdini.fixtures.ui.mock_hou_ui(monkeypatch: pytest.MonkeyPatch, mocker: MockerFixture) MockerFixture[source]

Mock the hou.ui module which isn’t available when running tests via Hython.

pytest_houdini.fixtures.ui.set_ui_available(monkeypatch: MonkeyPatch) None[source]

Fixture to set hou.isUIAvailable() to return True.

Module contents