Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V14 #1488

Merged
merged 6 commits into from
Jan 31, 2024
Merged

V14 #1488

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 14.0.0
--------------

- Fixed street suffixes for locale `Locale.HR`.
- Made `pytest-mimesis` a part of Mimesis itself.


Version 13.1.0
--------------

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
# built documents.
#
# The short X.Y version.
version = "13.1"
version = "14.0"
# The full version, including alpha/beta/rc tags.
release = "13.1.0"
release = "14.0.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
1 change: 1 addition & 0 deletions docs/contents.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ documentation explains the different parts of the Mimesis and how they can be us
providers
schema
random_and_seed
pytest_plugin
tips


Expand Down
66 changes: 66 additions & 0 deletions docs/pytest_plugin.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.. _pytest_plugin:

Integration with Pytest
=======================

Starting from version `14.0.0`, Mimesis now supports `pytest` out of the box. You no longer
require any third-party packages to seamlessly integrate Mimesis with `pytest`.


Usage
~~~~~

Using the personal provider as part of a test.

.. code-block:: python

# your_module/__init__.py

def validate_email(email):
# code that validates an e-mail address
return True


And your test file:

.. code-block:: python

from your_module import validate_email

def test_validate_email(mimesis):
assert validate_email(mimesis('email'))



You can also specify locales:


.. code-block:: python

from mimesis.locales import Locale

@pytest.mark.parameterize('mimesis_locale', [Locale.DE]) # use German locale
def test_create_user(mimesis):
assert create_user(name=mimesis('full_name'))


@pytest.mark.parameterize('mimesis_locale', [Locale.DE, Locale.EN, Locale.JP]) # test multiple locales
def test_add_phone(user, mimesis):
assert user.add_phone_number(name=mimesis('full_name'))



Fixtures
~~~~~~~~

We offer two public fixtures: `mimesis_locale` and `mimesis`. While `mimesis_locale` is
an enum object (e.g., `Locale.EN`, `Locale.RU`), `mimesis` is an instance of :class:`mimesis.schema.Field`.

See :class:`mimesis.enums.Locale`.


Impact on Test Speed
~~~~~~~~~~~~~~~~~~~~

We employ caching of Mimesis instances for various locales throughout the entire test session, making
the creation of new instances cost-effective.
2 changes: 0 additions & 2 deletions docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,5 @@ Integration with 3rd-party libraries
--------------------------------------

- `mimesis-factory`_ - Integration with ``factory_boy``.
- `pytest-mimesis`_ - is a pytest plugin that provides pytest fixtures for Mimesis providers.

.. _mimesis-factory: https://github.com/mimesis-lab/mimesis-factory
.. _pytest-mimesis: https://github.com/pytest-dev/pytest-mimesis
2 changes: 1 addition & 1 deletion mimesis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"__license__",
]

__version__ = "13.1.0"
__version__ = "14.0.0"
__title__ = "mimesis"
__description__ = "Mimesis: Fake Data Generator."
__url__ = "https://github.com/lk-geimfari/mimesis"
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mimesis"
version = "13.1.0"
version = "14.0.0"
description = "Mimesis: Fake Data Generator."
authors = ["Isaak Uchakaev <[email protected]>"]
license = "MIT"
Expand All @@ -19,9 +19,13 @@ keywords = [
"generate",
"mimesis",
"mock",
"schema",
"dataframe",
"populate",
"testing",
"pandas"
"pandas",
"polars",
"pytest"
]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
Loading