Mimesis integration with the pytest test runner
Project description
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
tests/test_email.py
:
from your_module import validate_email
def test_validate_email(mimesis):
assert validate_email(mimesis('email'))
Specifying 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.
License
pytest-mimesis is licensed under the MIT License.
Project details
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
File details
Details for the file pytest_mimesis-1.0.1.tar.gz
.
File metadata
- Download URL: pytest_mimesis-1.0.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.7.4 Darwin/18.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d7f80a9a9a3b0b903efc857ebf8f45af4a312a1b99ee078be63c2de903824d9 |
|
MD5 | f2e9db3146f791b6aee9d1cc77dc6d00 |
|
BLAKE2b-256 | c63f391a6b94e41312517f92214afff2a6a6057dd81693ce4eefe9972dda689b |
File details
Details for the file pytest_mimesis-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_mimesis-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.7.4 Darwin/18.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9de64b37f97707078b72a31bb868cf5676586b581cd25cabfdd8d1e35c41d90f |
|
MD5 | f19b61d2103f600d1cee3f4e09275ce5 |
|
BLAKE2b-256 | 4fb7363d3067e31fb8fd3ab5b12ddcca7dec20fac770c15bb700923c78d9ab16 |