Skip to main content

Mimesis integration with the pytest test runner

Project description

pytest-mimesis

Build Status wemake-python-styleguide

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

pytest_mimesis-1.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

pytest_mimesis-1.0.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_mimesis-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.11 CPython/3.7.2 Darwin/18.2.0

File hashes

Hashes for pytest_mimesis-1.0.0.tar.gz
Algorithm Hash digest
SHA256 17e34630eb9c955de68f42a9127f552e5704530de27779edf020e6cfd44e878d
MD5 89f4837961875a480fc1c8fd3c6b5117
BLAKE2b-256 74a81bb9ab8a49d31868c702ed160efca3881fd281c0165be9e77c58a3e5e690

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_mimesis-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.11 CPython/3.7.2 Darwin/18.2.0

File hashes

Hashes for pytest_mimesis-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4e22c33b7209fff9af02131a48a771c55bbd68a0492f9044e2961e8dc69f2f7
MD5 b5d40f2f0e5415b2c40c4c247c298df9
BLAKE2b-256 dfbf1291f7d870e9792e81ddebebbbc9fffa428c0bfd08cc60cfd5b86b909a84

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