-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from barseghyanartur/dev
Fixes in docs. Fixes in pdf_file and docx_file. (#85)
- Loading branch information
Showing
6 changed files
with
601 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.