AIBS Informatics Test Resources
Overview
This package provides a collection of utilities and resources to facilitate testing in various AIBS Informatics projects. It includes base test classes, mock utilities, and other helpful tools.
Available Modules
Base Test Class
The BaseTest class provides a base class for creating unit tests with common setup and teardown functionality. It includes the following features:
-
Environment Management:
set_env_vars(*key_values_pairs: Tuple[str, Optional[str]]): Set environment variables for the duration of the test.reset_environ: Class variable to reset environment variables after each test.
-
Temporary Files and Directories:
tmp_path(basename: Optional[str] = None) -> Path: Create a temporary directory.tmp_file(basename: Optional[str] = None, dirname: Optional[str] = None, content: Optional[str] = None) -> Path: Create a temporary file with optional content.
-
Assertions:
assertStringPattern(pattern: str, actual: str): Assert that a string matches a given regex pattern.assertJsonEqual(first: Union[dict, str, int, list], second: Union[dict, str, int, list]): Assert that two JSON objects are equal.assertListEqual(list1: List[Any], list2: List[Any], msg: Any = None, presort: bool = False, **presort_kwargs) -> None: Assert that two lists are equal, with an option to sort them before comparison.
-
Mocking:
create_patch(name: str, **kwargs) -> MagicMock: Create a patch for a given name and add it to the cleanup list.
-
Context Managers:
chdir(destination: Union[str, Path]): Context manager to change the current working directory temporarily.
Mock Utilities
does_not_raise: A context manager for assertions that no exceptions are raised.reset_environ_after_test: A decorator to reset environment variables after a test.
Example Usage
Here is an example of how to use the BaseTest class in your tests:
from aibs_informatics_test_resources import BaseTest
class MyTest(BaseTest):
def test_example(self):
self.assertEqual(1 + 1, 2)
def test_use_temp_file(self):
with self.tmp_file(content="Hello, World!") as tmp_file:
self.assertTrue(tmp_file.exists())
self.assertEqual(tmp_file.read_text(), "Hello, World!")
Contributing
Any and all PRs are welcome. Please see CONTRIBUTING.md for more information.
Licensing
This software is licensed under the Allen Institute Software License, which is the 2-clause BSD license plus a third clause that prohibits redistribution and use for commercial purposes without further permission. For more information, please visit Allen Institute Terms of Use.
Metadata
Release files for aibs-informatics-test-resources 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aibs_informatics_test_resources-0.1.1.tar.gz | 33.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aibs_informatics_test_resources-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.5 kB
Release files / aibs_informatics_test_resources-0.1.1.tar.gz
| Download URL | aibs_informatics_test_resources-0.1.1.tar.gz |
|---|---|
| Size | 33.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38ed39e1fa9644133903c6cd3e24a26ab193a44d4d47fb21aa18635dc53f6205
|
|
BLAKE2b-256 checksum How to use checksums |
53701dc8b0707e457f2005a5a68f0aadeff64a48582b6084ae07b5a34ca67b59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 15, 2025.
Transparency logRelease files / aibs_informatics_test_resources-0.1.1-py3-none-any.whl
| Download URL | aibs_informatics_test_resources-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5b69ac3e51c36123297627c63edfac13828128033868c56d4bb06747724bfc2
|
|
BLAKE2b-256 checksum How to use checksums |
edb8f9773b5ba17c0f94267abfdc35a97f5236ed89b8763923d7ae9ce5ca95b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 15, 2025.
Transparency log