pytest-cfg-fetcher
Unit tests don't take arguments. Sometimes we like to pass an arg or two, e.g. you want to write test results to a file when running locally. This is a simple function to do that.
pytest-cfg-fetcher assumes you have a directory called _test-config/ in the same directory as your unit tests, e.g. under test/. The _test-config/ dir contains a config.json file/
_test-config/config.json contians minimally:
{
"test_out_path": <path>
}
which is a local path where you might want to write output for tests.
The fetch_config() function takes a single argument, which should be the name of the test that calls it -- the return value is a dict object containing the test_out_path and whatever else you want to pass into your unit tests.
{
"test_out_path": "test/_test-result",
"my_test" {
"my_test_bool_opt": true,
"my_test_str_opt": "stringalingting"
}
}
Installation
pip install pytest-cfg-fetcher
Usage
# mytest.py
from pytest-cfg-fetcher.fetch import fetch_config
import unittest
class Test(unittest.TestCase):
def test_import(self):
config = fetch_config("my_test")
...
testy stuf
...
test_result = "results of test"
if config and config['my_test_bool_opt']:
with open(f"{config['test_out_path']}/{config['my_test_str_opt']}.txt", "w+") as out:
out.write(test_result)
if __name__ == '__main__':
unittest.main()
Metadata
Release files for pytest-cfg-fetcher 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 | Provenance | |
|---|---|---|---|---|
| pytest_cfg_fetcher-0.1.1.tar.gz | 1.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_cfg_fetcher-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.8 kB
Release files / pytest_cfg_fetcher-0.1.1.tar.gz
| Download URL | pytest_cfg_fetcher-0.1.1.tar.gz |
|---|---|
| Size | 1.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d7e6c8cec9aac137a54dc95054ce39aa5cc378a7baf09fa322fce58247dabe8
|
|
BLAKE2b-256 checksum How to use checksums |
8ce26e6af124e4962e218eb3e3e3bbdd8ba8e0579bf9c2f567792f8b274b97c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.1 CPython/3.9.18 Linux/6.2.0-1019-azure
|
Release files / pytest_cfg_fetcher-0.1.1-py3-none-any.whl
| Download URL | pytest_cfg_fetcher-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8fa2720c4077ee6a7031335a39d8d9eb50f19240bddaf58b48c56979125f9cea
|
|
BLAKE2b-256 checksum How to use checksums |
5661ec9d2055fe4e92fcc840f39e56435c542d3d6a3cd2dd271f90861322df05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.1 CPython/3.9.18 Linux/6.2.0-1019-azure
|
Security for pytest-cfg-fetcher 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.