Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pytest-dev/pytest-mimesis
Mimesis integration with the pytest test runner. This plugin provider useful fixtures based on providers from Mimesis.
https://github.com/pytest-dev/pytest-mimesis
fake-data faker fixtures mimesis plugin pytest pytest-mimesis pytest-plugin testing testing-tools
Last synced: 27 days ago
JSON representation
Mimesis integration with the pytest test runner. This plugin provider useful fixtures based on providers from Mimesis.
- Host: GitHub
- URL: https://github.com/pytest-dev/pytest-mimesis
- Owner: pytest-dev
- License: mit
- Archived: true
- Created: 2017-02-16T19:48:55.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-31T14:22:47.000Z (11 months ago)
- Last Synced: 2024-11-10T03:42:21.569Z (about 1 month ago)
- Topics: fake-data, faker, fixtures, mimesis, plugin, pytest, pytest-mimesis, pytest-plugin, testing, testing-tools
- Language: Python
- Homepage: https://pypi.org/project/pytest-mimesis/
- Size: 194 KB
- Stars: 62
- Watchers: 44
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-pytest - pytest-mimesis - Mimesis integration with the pytest test runner. Generate fake data in your tests. (Plugins)
README
# ⛔️ DEPRECATED
This repository is now deprecated. We have integrated `pytest-mimesis` into mimesis itself, and there is no longer a need to use a separate package. Refer to the [Integration with Pytest](https://mimesis.name/en/v14.0.0/pytest_plugin.html) section for more details.
## pytest-mimesis
[![test](https://github.com/pytest-dev/pytest-mimesis/actions/workflows/test.yml/badge.svg)](https://github.com/pytest-dev/pytest-mimesis/actions/workflows/test.yml)
[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)
[![Python Version](https://img.shields.io/pypi/pyversions/pytest-mimesis.svg)](https://pypi.org/project/pytest-mimesis/)**pytest-mimesis** is a pytest plugin that provides pytest fixtures for [Mimesis](https://github.com/lk-geimfari/mimesis) providers. This allows you to quickly and easily use randomized, dummy data as part of your test suite.
## Installation
```bash
pip install pytest-mimesis
```## Examples
Using the personal provider as part of a test.
```python
# your_module/__init__.pydef validate_email(email):
# code that validates an e-mail address
return True
```And your test file:
```python
# tests/test_email.pyfrom your_module import validate_email
def test_validate_email(mimesis):
assert validate_email(mimesis('email'))
```You can also specify locales:
```python
@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](https://github.com/lk-geimfari/mimesis) itself, it is awesome!
- [mimesis-factory](https://github.com/mimesis-lab/mimesis-factory) which brings `factory_boy` integration to `mimesis`## License
pytest-mimesis is licensed under the [MIT License](https://github.com/pytest-dev/pytest-mimesis/blob/master/LICENSE).