Skip to main content

Mimesis integration with the pytest test runner

Project description

pytest-mimesis

Build Status

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

or

➜ ~ git clone https://github.com/mimesis-lab/pytest-mimesis.git
➜ ~ cd pytest-mimesis/
➜  make install

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

pytest_mimesis-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

pytest_mimesis-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_mimesis-0.1.0.tar.gz.

File metadata

File hashes

Hashes for pytest_mimesis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fac8bcb7952e5751ab0e0b20ab61a76d02831d286a66ed0963c9c19e8858e63b
MD5 e9cc25d3546772306f14ebe1b14ce30a
BLAKE2b-256 143db844aceb3338d260cc34994dbe5436d43742cfab6a0d9c5dfaf22b49c864

See more details on using hashes here.

File details

Details for the file pytest_mimesis-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_mimesis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5768258731fe4cc3eebe0652829178c89295a158ec9b78633889667d6d772fc2
MD5 223db1c353aa1e019741d2922e21f130
BLAKE2b-256 71341cee5121c9abea232add06a6242085900d2de7882eb1042fd5495ccd3683

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page