You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
There are also two potential bugs I detect. The first is the test on test_typeguard.py::test_exec_no_namespace, the test will fail on pytest. The second bug is on test_typeguard.py::test_forward_ref_policy_guess, where the test can pass the first test run but fail started on the second test run.
To Reproduce
for the bug on test_typeguard.py::test_exec_no_namespace
run pytest pytest tests/test_typeguard.py
for the bug on test_typeguard.py::test_forward_ref_policy_guess
install pytest flaky finder with pip install pytest-flakefinder
run pytest with flake-finder with command pytest -k tests/test_typeguard.py --flake-finder --flake-runs=5
Expected behavior
The test_typeguard will have one fail on normal pytest run and 9 fails with flake-finder, shown as below
test_typeguard.py ......................................................................FFFFF................................................ [ 11%]
............................................................................................................................................. [ 25%]
............................................................................................................................................. [ 38%]
............................................................................................................................................. [ 52%]
............................................................................................................................................. [ 66%]
............................................................................................................................................. [ 79%]
............................................................................................................................................. [ 93%]
..............................................................FFFF.....
Where the first 5 fail is from test_exec_no_namespace and the later 4 is from test_forward_ref_policy_guess
The fail message of test_exec_no_namespace will be tests/test_typeguard.py:161: in test_exec_no_namespace """), {}) <string>:4: in <module> ??? ../.local/lib/python3.6/site-packages/typeguard/__init__.py:1015: in typechecked warn('no type annotations present -- not typechecking {}'.format(function_name(func))) ../.local/lib/python3.6/site-packages/typeguard/__init__.py:355: in function_name qualname = (module + '.') if module not in ('builtins', '') else '' E TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
and for test_forward_ref_policy_guess
tests/test_typeguard.py:1528: in test_forward_ref_policy_guess unresolvable_annotation(collections.OrderedDict()) E Failed: DID NOT WARN. No warnings of type (<class 'typeguard.TypeHintWarning'>,) was emitted. The list of emitted warnings is: [].
Additional context
For test_exec_no_namespace the reason seems related to the python library textwrap.py where it use text = re.sub(r'(?m)^' + margin, '', text) but as the error message shown, unsupported operand type(s) for +: 'NoneType' and 'str' it might related to the import context but I'm not sure.
For test_forward_ref_policy_guess the reason seems like related to the pytest warning suppressed where same warning will be emit on the second times, you can also check this issue, where it seems can be resolved by changing the pytest setup, it is also fine if the developer considers the fail on multiple runs doesn't need to be concerned.
I also create a PR fix another function on test_typeguard.py and it is this PR
The text was updated successfully, but these errors were encountered:
lonly7star
changed the title
potential Bugon test_typeguard.py::test_exec_no_namespace and test_typeguard.py::test_forward_ref_policy_guess
potential Bug on test_typeguard.py::test_exec_no_namespace and test_typeguard.py::test_forward_ref_policy_guess
Nov 28, 2021
I've fixed the warning caused by test_exec_no_namespace. The TypeChecker tests are not a concern because this is a deprecated feature that has already been dropped in the 3.0 branch.
Describe the bug
There are also two potential bugs I detect. The first is the test on test_typeguard.py::test_exec_no_namespace, the test will fail on pytest. The second bug is on test_typeguard.py::test_forward_ref_policy_guess, where the test can pass the first test run but fail started on the second test run.
To Reproduce
for the bug on
test_typeguard.py::test_exec_no_namespace
pytest tests/test_typeguard.py
for the bug on
test_typeguard.py::test_forward_ref_policy_guess
pip install pytest-flakefinder
pytest -k tests/test_typeguard.py --flake-finder --flake-runs=5
Expected behavior
The test_typeguard will have one fail on normal pytest run and 9 fails with flake-finder, shown as below
test_typeguard.py ......................................................................FFFFF................................................ [ 11%]
............................................................................................................................................. [ 25%]
............................................................................................................................................. [ 38%]
............................................................................................................................................. [ 52%]
............................................................................................................................................. [ 66%]
............................................................................................................................................. [ 79%]
............................................................................................................................................. [ 93%]
..............................................................FFFF.....
Where the first 5 fail is from
test_exec_no_namespace
and the later 4 is fromtest_forward_ref_policy_guess
The fail message of
test_exec_no_namespace
will betests/test_typeguard.py:161: in test_exec_no_namespace """), {})
<string>:4: in <module> ???
../.local/lib/python3.6/site-packages/typeguard/__init__.py:1015: in typechecked
warn('no type annotations present -- not typechecking {}'.format(function_name(func)))
../.local/lib/python3.6/site-packages/typeguard/__init__.py:355: in function_name
qualname = (module + '.') if module not in ('builtins', '') else ''
E TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
and for
test_forward_ref_policy_guess
tests/test_typeguard.py:1528: in test_forward_ref_policy_guess
unresolvable_annotation(collections.OrderedDict())
E Failed: DID NOT WARN. No warnings of type (<class 'typeguard.TypeHintWarning'>,) was emitted. The list of emitted warnings is: [].
Additional context
For
test_exec_no_namespace
the reason seems related to the python librarytextwrap.py
where it usetext = re.sub(r'(?m)^' + margin, '', text)
but as the error message shown,unsupported operand type(s) for +: 'NoneType' and 'str'
it might related to the import context but I'm not sure.For
test_forward_ref_policy_guess
the reason seems like related to the pytest warning suppressed where same warning will be emit on the second times, you can also check this issue, where it seems can be resolved by changing the pytest setup, it is also fine if the developer considers the fail on multiple runs doesn't need to be concerned.I also create a PR fix another function on
test_typeguard.py
and it is this PRThe text was updated successfully, but these errors were encountered: