Giter VIP home page Giter VIP logo

pytest-mimesis's Introduction

pytest-mimesis

test wemake-python-styleguide Python Version

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:

License

pytest-mimesis is licensed under the MIT License.

pytest-mimesis's People

Contributors

lk-geimfari avatar sobolevn avatar dependabot-support avatar dependabot-preview[bot] avatar wikkiewikkie avatar hugovk avatar eumiro avatar geyser avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.