Skip to content

Commit

Permalink
Disable buitin warning summary and buitify output
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis committed Mar 28, 2024
1 parent 1c3e38b commit b1bf434
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ fixture-parentheses = false
# * Disable `flaky` plugin for pytest. This plugin conflicts with `rerunfailures` because provide same marker.
# * Disable `nose` builtin plugin for pytest. This feature deprecated in 7.2 and will be removed in pytest>=8
# * And we focus on use native pytest capabilities rather than adopt another frameworks.
addopts = "-rasl --verbosity=2 -p no:flaky -p no:nose --asyncio-mode=strict"
# * Disable warnings summary, because we use our warning summary.
addopts = "-rasl --verbosity=2 -p no:flaky -p no:nose --asyncio-mode=strict --disable-warnings"
norecursedirs = [
".eggs",
"airflow",
Expand All @@ -472,9 +473,12 @@ filterwarnings = [
"ignore::DeprecationWarning:flask_sqlalchemy",
# https://github.com/dpgaspar/Flask-AppBuilder/pull/1903
"ignore::DeprecationWarning:apispec.utils",
# Connexion 2 use Validator.iter_errors, should be resolved into Connexion 3
# Connexion 2 use different deprecated objects, this should be resolved into Connexion 3
# https://github.com/spec-first/connexion/pull/1536
"ignore::DeprecationWarning:connexion.spec",
'ignore::DeprecationWarning:connexion.spec',
'ignore:jsonschema\.RefResolver:DeprecationWarning:connexion.json_schema',
'ignore:jsonschema\.exceptions\.RefResolutionError:DeprecationWarning:connexion.json_schema',
'ignore:Accessing jsonschema\.draft4_format_checker:DeprecationWarning:connexion.decorators.validation',
]
python_files = [
"test_*.py",
Expand Down
14 changes: 9 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,11 +1306,12 @@ def format_test_function_location(item):
yield

if captured_warnings:
print("\n ======================== Warning summary =============================\n")
print(f" The tests generated {sum(captured_warnings_count.values())} warnings.")
print(f" After removing duplicates, {len(captured_warnings.values())} of them remained.")
print(f" They are stored in {warning_output_path} file.")
print("\n ======================================================================\n")
terminalreporter.section(
f"Warning summary. Total: {sum(captured_warnings_count.values())}, "
f"Unique: {len(captured_warnings.values())}",
yellow=True,
bold=True,
)
warnings_as_json = []

for warning in captured_warnings.values():
Expand Down Expand Up @@ -1340,6 +1341,9 @@ def format_test_function_location(item):
for i in warnings_as_json:
f.write(f'{i["path"]}:{i["lineno"]}: [W0513(warning), ] {i["warning_message"]}')
f.write("\n")
terminalreporter.write("Warnings saved into ")
terminalreporter.write(os.fspath(warning_output_path), yellow=True)
terminalreporter.write(" file.")
else:
# nothing, clear file
with warning_output_path.open("w") as f:
Expand Down

0 comments on commit b1bf434

Please sign in to comment.