bloc.test#

Functions#

get_test_file(*paths)

Return the absolute path to a test file.

defaults()

Return Parser object containing default configuration.

default_simulation(initial, phases[, settings])

Return a default Reactor Net simulation, to be used in other tests.

Module Contents#

bloc.test.get_test_file(*paths)#

Return the absolute path to a test file.

This utility function constructs paths to files in the tests/ directory, ensuring tests work correctly across different operating systems and execution contexts (local development vs CI/CD environments).

Parameters:

*paths (str) – Path components relative to the tests/ directory. For example: “configs”, “mix_react_streams.yaml”

Returns:

The absolute path to the test file.

Return type:

Path

Examples

Get a test configuration file:

>>> from bloc.test import get_test_file
>>> config_path = get_test_file("configs", "mix_react_streams.yaml")
>>> print(config_path)
/path/to/bloc/tests/configs/mix_react_streams.yaml

Get a test data file:

>>> csv_path = get_test_file("test_file_nobili_carbon_quality.csv")
>>> df = pd.read_csv(csv_path)

Use with YAML loading functions:

>>> from bloc.yaml_utils import load_yaml_with_inheritance
>>> config_path = get_test_file("configs", "mix_react_streams.yaml")
>>> config = load_yaml_with_inheritance(str(config_path))
Raises:

FileNotFoundError – If the constructed path does not exist.

See also

bloc.utils.get_root

Get the root bloc directory

bloc.utils.get_path_to_data

Get paths to data files

bloc.test.defaults()#

Return Parser object containing default configuration.

bloc.test.default_simulation(initial, phases, settings=None)#

Return a default Reactor Net simulation, to be used in other tests.

Example

::

from bloc.ctutils import defaults, default_simulation config = defaults() sim = default_simulation(**config)