Skip to content

Commit

Permalink
Merge pull request #86 from barseghyanartur/dev
Browse files Browse the repository at this point in the history
Fixes in docs. Fixes in pdf_file and docx_file. (#85)
  • Loading branch information
barseghyanartur committed May 9, 2024
2 parents 4307cfb + 58682d2 commit 92f5892
Show file tree
Hide file tree
Showing 6 changed files with 601 additions and 165 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.6.9
-----
2024-05-10

- Minor fixes in ``pdf_file`` and ``docx_file`` providers.
- Minor fixes in docs.

0.6.8
-----
2024-05-06
Expand Down
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ As files on the file system
FAKER.gif_file() # str
FAKER.txt_file() # str
Factories
---------
Factories/dynamic fixtures
--------------------------
This is how you could define factories for `Django`_'s built-in ``Group``
and ``User`` models.

.. code-block:: python
:name: test_factories
from django.contrib.auth.models import Group, User
from fake import (
Expand Down
51 changes: 51 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
Configuration hooks for `pytest`. Normally this wouldn't be necessary,
but since `pytest-rst` is used, we want to clean-up files generated by
running documentation tests. Therefore, this hook, which simply
calls the `clean_up` method of the `FILE_REGISTRY` instance.
"""
import pytest
from fake import FILE_REGISTRY

__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
__copyright__ = "2023-2024 Artur Barseghyan"
__license__ = "MIT"
__all__ = (
"pytest_runtest_setup",
"pytest_runtest_teardown",
)


def pytest_collection_modifyitems(session, config, items):
"""Modify test items during collection."""
for item in items:
try:
from pytest_rst import RSTTestItem

if isinstance(item, RSTTestItem):
# Dynamically add marker to RSTTestItem tests
item.add_marker(pytest.mark.django_db(transaction=True))
except ImportError:
pass


def pytest_runtest_setup(item):
"""Setup before test runs."""
try:
from pytest_rst import RSTTestItem

if isinstance(item, RSTTestItem):
pass
except ImportError:
pass


def pytest_runtest_teardown(item, nextitem):
"""Clean up after test ends."""
try:
from pytest_rst import RSTTestItem

if isinstance(item, RSTTestItem):
FILE_REGISTRY.clean_up()
except ImportError:
pass

0 comments on commit 92f5892

Please sign in to comment.