-
Notifications
You must be signed in to change notification settings - Fork 1
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 #107 from jedie/dev
Apply https://github.com/jedie/cookiecutter_templates updates
- Loading branch information
Showing
6 changed files
with
89 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
__pycache__ | ||
/dist/ | ||
/coverage.* | ||
*.orig | ||
|
||
!.github | ||
!.editorconfig | ||
|
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
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 |
---|---|---|
@@ -1,15 +1,31 @@ | ||
import os | ||
import unittest.util | ||
from pathlib import Path | ||
|
||
from manageprojects.utilities.log_utils import log_config | ||
from bx_py_utils.test_utils.deny_requests import deny_any_real_request | ||
from cli_base.cli_tools.verbosity import MAX_LOG_LEVEL, setup_logging | ||
from rich import print # noqa | ||
|
||
|
||
# Hacky way to expand the failed test output: | ||
unittest.util._MAX_LENGTH = os.environ.get('UNITTEST_MAX_LENGTH', 300) | ||
def pre_configure_tests() -> None: | ||
print(f'Configure unittests via "load_tests Protocol" from {Path(__file__).relative_to(Path.cwd())}') | ||
|
||
# Hacky way to display more "assert"-Context in failing tests: | ||
_MIN_MAX_DIFF = unittest.util._MAX_LENGTH - unittest.util._MIN_DIFF_LEN | ||
unittest.util._MAX_LENGTH = int(os.environ.get('UNITTEST_MAX_LENGTH', 300)) | ||
unittest.util._MIN_DIFF_LEN = unittest.util._MAX_LENGTH - _MIN_MAX_DIFF | ||
|
||
log_config( | ||
format='%(levelname)s %(name)s.%(funcName)s %(lineno)d | %(message)s', | ||
log_in_file=False, | ||
raise_log_output=True, | ||
) | ||
# Deny any request via docket/urllib3 because tests they should mock all requests: | ||
deny_any_real_request() | ||
|
||
# Display DEBUG logs in tests: | ||
setup_logging(verbosity=MAX_LOG_LEVEL) | ||
|
||
|
||
def load_tests(loader, tests, pattern): | ||
""" | ||
Use unittest "load_tests Protocol" as a hook to setup test environment before running tests. | ||
https://docs.python.org/3/library/unittest.html#load-tests-protocol | ||
""" | ||
pre_configure_tests() | ||
return loader.discover(start_dir=Path(__file__).parent, pattern=pattern) |
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