pytest-mimesis
pytest-mimesis is a pytest plugin that provides pytest fixtures for Mimesis providers. This allows you to quickly and easily use randomized, dummy data as part of your test suite.
Installation
pip install pytest-mimesis
Examples
Using the personal provider as part of a test.
# your_module/__init__.py
def validate_email(email):
# code that validates an e-mail address
return True
And your test file:
# tests/test_email.py
from your_module import validate_email
def test_validate_email(mimesis):
assert validate_email(mimesis('email'))
You can also specify locales:
@pytest.mark.parameterize('mimesis_locale', ['de']) # use German locale
def test_create_user(mimesis):
assert create_user(name=mimesis('full_name'))
@pytest.mark.parameterize('mimesis_locale', ['de', 'en', 'jp']) # test multiple locales
def test_add_phone(user, mimesis):
assert user.add_phone_number(name=mimesis('full_name'))
Fixtures
We provide two public fixtures: mimesis_locale and mimesis.
While mimesis_locale is just a string (like: en, ru),
mimesis is an instance of mimesis.schema.Field.
We use caching of mimesis instances for different locales for the whole
test session, so creating new instances is cheap.
Related projects
You might also be interested in:
- mimesis itself, it is awesome!
- mimesis-factory which brings
factory_boyintegration tomimesis
License
pytest-mimesis is licensed under the MIT License.
Release files for pytest-mimesis 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_mimesis-1.1.0.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_mimesis-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / pytest_mimesis-1.1.0.tar.gz
| Download URL | pytest_mimesis-1.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26a152067e2de0a0dae8e5045710524785646f8b68c6efdc336b73f15ee292e3
|
|
BLAKE2b-256 checksum How to use checksums |
bb370b0ecfcee75ef3b9d92592e2402df81de2f795bf4e266c3beb3df7c4f325
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.4 CPython/3.7.2 Darwin/18.6.0
|
Release files / pytest_mimesis-1.1.0-py3-none-any.whl
| Download URL | pytest_mimesis-1.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5cc30a967ee14d50f44074e7bb93f9e9a58b202ef08047deb237efa1e462155d
|
|
BLAKE2b-256 checksum How to use checksums |
30a01ea9feff6e816800a7d096ae1ca6e588892561fa7bacc96933f8c1ebd42f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.4 CPython/3.7.2 Darwin/18.6.0
|