Utils

Tests for reprospect.utils.

CMake

class tests.utils.test_cmake.TestFileAPIView on GitHub

Bases: object

Tests for reprospect.utils.cmake.FileAPI.

cmake_file_api() FileAPIView on GitHub
test_cache(cmake_file_api: FileAPI) NoneView on GitHub

Check that cache variables are read correctly.

test_codemodel_configuration(cmake_file_api: FileAPI) NoneView on GitHub

Check codemodel configuration information.

test_target(cmake_file_api: FileAPI) NoneView on GitHub

Check target information.

test_toolchains(cmake_file_api: FileAPI) NoneView on GitHub

Check toolchain information.

Detect GPUs

class tests.utils.test_detect.TestGPUDetectorView on GitHub

Bases: object

Tests for reprospect.utils.detect.GPUDetector.

OUTPUT = b'index, uuid, name, compute_cap\n0, GPU-12345678-1234-1234-1234-123456789012, NVIDIA GeForce RTX 3090, 8.6\n1, GPU-87654321-4321-4321-4321-210987654321, NVIDIA A100-SXM4-40GB, 8.0\n'
test_detect_gpus() NoneView on GitHub

Test that reprospect.utils.detect.GPUDetector.get() returns a properly formatted pandas.DataFrame.

test_detect_gpus_cache() NoneView on GitHub

Test that calling reprospect.utils.detect.GPUDetector.get() twice uses caching and only calls nvidia-smi once.

test_detect_gpus_no_cache() NoneView on GitHub

Test that calling reprospect.utils.detect.GPUDetector.get() twice when caching is disabled calls nvidia-smi twice.

test_detect_gpus_no_gpu() NoneView on GitHub

Test that reprospect.utils.detect.GPUDetector.get() returns an empty pandas.DataFrame if nvidia-smi is not found.

class tests.utils.test_detect.TestGPUDetectorAsScriptView on GitHub

Bases: object

Tests for reprospect.utils.detect in script mode.

SCRIPT: Final[str] = '/__w/reprospect/reprospect/reprospect/utils/detect.py'
test(capsys) NoneView on GitHub

Check that the output is correctly formatted according to the arguments.

Environment

class tests.utils.test_environment.TestEnvironmentFieldView on GitHub

Bases: object

Tests for reprospect.utils.environment.EnvironmentField.

test_converter_from_default_type(monkeypatch) NoneView on GitHub

If no converter was provided, infer it from the type of the default value.

test_in_environment_converted_no_env_key(monkeypatch) NoneView on GitHub

The attribute is correctly initialized from the environment (no key given), and converted.

test_in_environment_converted_with_env_key(monkeypatch) NoneView on GitHub

The value is correctly initialized from the environment (given a key), and converted.

test_no_attribute_name_or_env_key() NoneView on GitHub

Raises if neither an attribute name nor an environment key is given.

test_not_in_environment_no_default() NoneView on GitHub

The attribute cannot be initialized.

test_not_in_environment_use_default() NoneView on GitHub

The value is initialized to the given default value.

test_read_int_converter(monkeypatch) NoneView on GitHub

Environment variable read as int.

test_read_str_converter(monkeypatch) NoneView on GitHub

Environment variable read as str.

test_reset(monkeypatch) NoneView on GitHub
test_value_cached_at_class_level(monkeypatch) NoneView on GitHub

The value is shared among all instances.

subprocess

class tests.utils.test_subprocess_helpers.TestPopenStreamView on GitHub

Bases: object

Tests for reprospect.utils.subprocess_helpers.popen_stream.

static mocker(*, wait: int, stdout: str | None = None, stderr: str | None = None) MagicMockView on GitHub
test_command_failure() NoneView on GitHub

The command fails.

test_command_not_found() NoneView on GitHub

The command is not found.

test_empty_output() NoneView on GitHub

Empty stdout.

test_generator_break(caplog) NoneView on GitHub

Break while the generator is not finished.

test_lazy() NoneView on GitHub

Use an iterator to read line-by-line.

test_path() NoneView on GitHub

The command contains pathlib.Path.

test_str() NoneView on GitHub

The command is composed of strings.

Type information

class tests.utils.test_types.TestKindView on GitHub

Bases: object

Tests for reprospect.utils.types.Kind.

test_from_numpy() NoneView on GitHub
class tests.utils.test_types.TestTypeInfoView on GitHub

Bases: object

Tests for reprospect.utils.types.TypeInfo.

test_itemsize() NoneView on GitHub
test_normalize_from_int() NoneView on GitHub
test_normalize_from_numpy() NoneView on GitHub
test_normalize_from_self() NoneView on GitHub