unit test resources for AIBS informatics packages
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aibs_informatics_test_resources-0.1.1.tar.gz.
File metadata
- Download URL: aibs_informatics_test_resources-0.1.1.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38ed39e1fa9644133903c6cd3e24a26ab193a44d4d47fb21aa18635dc53f6205
|
|
| MD5 |
28c0872964c95061d336922d1c0512a6
|
|
| BLAKE2b-256 |
53701dc8b0707e457f2005a5a68f0aadeff64a48582b6084ae07b5a34ca67b59
|
Provenance
The following attestation bundles were made for aibs_informatics_test_resources-0.1.1.tar.gz:
Publisher:
release.yml on AllenInstitute/aibs-informatics-test-resources
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aibs_informatics_test_resources-0.1.1.tar.gz -
Subject digest:
38ed39e1fa9644133903c6cd3e24a26ab193a44d4d47fb21aa18635dc53f6205 - Sigstore transparency entry: 162402172
- Sigstore integration time:
-
Permalink:
AllenInstitute/aibs-informatics-test-resources@5d72d72b41041bc567eab02573f9aa37170aa470 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AllenInstitute
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5d72d72b41041bc567eab02573f9aa37170aa470 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file aibs_informatics_test_resources-0.1.1-py3-none-any.whl.
File metadata
- Download URL: aibs_informatics_test_resources-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5b69ac3e51c36123297627c63edfac13828128033868c56d4bb06747724bfc2
|
|
| MD5 |
3ec1012761142e61c153f567ed86070b
|
|
| BLAKE2b-256 |
edb8f9773b5ba17c0f94267abfdc35a97f5236ed89b8763923d7ae9ce5ca95b9
|
Provenance
The following attestation bundles were made for aibs_informatics_test_resources-0.1.1-py3-none-any.whl:
Publisher:
release.yml on AllenInstitute/aibs-informatics-test-resources
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aibs_informatics_test_resources-0.1.1-py3-none-any.whl -
Subject digest:
d5b69ac3e51c36123297627c63edfac13828128033868c56d4bb06747724bfc2 - Sigstore transparency entry: 162402181
- Sigstore integration time:
-
Permalink:
AllenInstitute/aibs-informatics-test-resources@5d72d72b41041bc567eab02573f9aa37170aa470 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AllenInstitute
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5d72d72b41041bc567eab02573f9aa37170aa470 -
Trigger Event:
workflow_dispatch
-
Statement type: