OpenAssetIO
An abstract API for generalising interactions between a host application and an asset management system
|
A unittest
based test harness that allows manager plugin developers to check that their implementation meets the requirements of the API.
More...
Classes | |
class | FixtureAugmentedTestCase |
Base test case class that all test classes must inherit from. More... | |
Functions | |
def | executeSuite (testSuiteModule, fixtures, unittestExtraArgs=None) |
Executes the supplied test suite with the given fixtures, optionally passing extra arguments to the underlying unittest framework. More... | |
def | fixturesFromPyFile (path) |
Loads a fixtures dict from the specified python file. More... | |
def | moduleFromFile (path) |
Loads a python module from the specified file, without it needing to be on PYTHONPATH. More... | |
A unittest
based test harness that allows manager plugin developers to check that their implementation meets the requirements of the API.
The harness can be invoked programatically or via tha CLI. The module exposes the main test entry point and fixture loading methods. This permits additional test suites to be written and run by the developer, to test manager-specific functionality if desired.
def openassetio.test.manager.harness.executeSuite | ( | testSuiteModule, | |
fixtures, | |||
unittestExtraArgs = None |
|||
) |
Executes the supplied test suite with the given fixtures, optionally passing extra arguments to the underlying unittest framework.
testSuiteModule | module A module of test cases deriving from FixtureAugmentedTestCase . |
fixtures | dict The fixtures corresponding to the supplied testSuiteModule. |
unittestExtraArgs | List[str] Additional args to pass to the unittest framework, see unittest.main argv for more details. |
bool
True if the suite passed, False if there was one or more failures.The format of the fixtures dictionary is as follows:
Where:
Test_Case_name
: The name of a test class
declaration within the supplied suite that derives from FixtureAugmentedTestCase.Test_function_name
: The the name of a test function defined within the named class.fixture_name
: The name of a fixture queried by the test function. This may be an input value, or an expected result.shared
: Fixtures values that will be inherited to inner classes or functions.The test harness takes care of extracting the appropriate function sub-dictionary and making it available through self._fixtures
.
NOTE: Fixture names need to be valid python variable names, and should only contain alpha-numeric characters and underscores.
def openassetio.test.manager.harness.fixturesFromPyFile | ( | path | ) |
Loads a fixtures dict from the specified python file.
The supplied path should point to a python file defining a top-level fixtures
variable holding a dict
, populated with the required fixtures for the target test suite.
path | str The path to the file to load fixtures from. |
dict
The fixtures dict defined by the supplied file.def openassetio.test.manager.harness.moduleFromFile | ( | path | ) |
Loads a python module from the specified file, without it needing to be on PYTHONPATH.
The file name is used as the module name. This can be useful to load test suites from files that are not otherwise on PYTHONPATH.
path | str The path to the file to load the module from. |
Copyright 2013-2023 The Foundry Visionmongers Ltd. OpenAssetIO is released under the Apache 2.0 License