ibllib.tests.base
Module attributes
When False (INTEGRATION_DATA_WRITABLE=0), IntegrationTest.setUpClass creates a writable symlink mirror of required_files under a TemporaryDirectory so tests can write output files without touching the read-only data mount (e.g. S3). |
Functions
Decorator to temporarily disable the log. |
|
Get the set of session eids used in integration tests. |
|
This creates symlinks to a scratch directory to start an extraction while leaving the raw data untouched. |
Classes
Base class for tests that require S3 integration data. |
|
A class to record test durations |
|
A class that prints a list of the slowest tests to the output stream |
- INTEGRATION_DATA_WRITABLE = True
When False (INTEGRATION_DATA_WRITABLE=0), IntegrationTest.setUpClass creates a writable symlink mirror of required_files under a TemporaryDirectory so tests can write output files without touching the read-only data mount (e.g. S3).
- class TimeLoggingTestResult(*args, **kwargs)[source]
Bases:
TextTestResultA class to record test durations
- class TimeLoggingTestRunner(slow_test_threshold=0.3, *args, **kwargs)[source]
Bases:
TextTestRunnerA class that prints a list of the slowest tests to the output stream
- class IntegrationTest(*args, **kwargs)[source]
Bases:
TestCaseBase class for tests that require S3 integration data.
Subclass this for any test needing integration data. When INTEGRATION_DATA_DIR is unset or missing (e.g. an outside contributor running plain python -m unittest discover), these tests auto-skip, so the unit suite still runs cleanly.
- required_files = []
An optional list of required files/folders to glob for, relative to data_path.
- data_path = PosixPath('.')
Active data root. Resolves to the writable temp dir when active, else the configured root. Works on both classes (cls.data_path in setUpClass) and instances (self.data_path in tests). Subclasses may narrow it: self.data_path = self.data_path / subdir.
- classmethod setUpClass()[source]
Hook method for setting up class fixture before running tests in the class.
- classmethod tearDownClass()[source]
Hook method for deconstructing the class fixture after running all tests in the class.
- classmethod default_data_root()[source]
Returns the configured data root (class-level temp dir if active, else INTEGRATION_DATA_DIR).
For instance-level path resolution (e.g. in setUp or test methods), use self.data_path instead — it also checks for instance-level temp dirs created by _writable_scope=’test’.
- list_current_sessions(one=None)[source]
Get the set of session eids used in integration tests. When writing new tests, this can be a useful way of choosing which sessions to use.
- Parameters:
one – An ONE object for fetching session eid from path
- Returns:
Set of integration session eids
- disable_log(level=50, restore_level=None, quiet=False)[source]
Decorator to temporarily disable the log.
- Parameters:
level – The minimum logging level to disable
restore_level – The logging level to restore
quiet – If false the fact that the log is disabled will be printed
- Returns:
- make_sym_links(source_path, extraction_path=None, fallback_to_copy=True)[source]
This creates symlinks to a scratch directory to start an extraction while leaving the raw data untouched.
- Parameters:
source_path – location containing the extraction fixture
extraction_path – (None) scratch location where the symlinks will end up,
omitting the session parts example: “/tmp”. If set to None, it will create a temporary directory using tempdir. :param fallback_to_copy: (True) if the symlink fails, it will copy the file instead. :return: