[New-bugs-announce] [issue46299] Improve several exception handling practices in `test_descr.py`

Nikita Sobolev report at bugs.python.org
Fri Jan 7 17:38:58 EST 2022


New submission from Nikita Sobolev <mail at sobolevn.me>:

There are several problems in `test_descr.py` that I've found:
1. In `test_dir` there's a test case that ensure that `TypeError` is raised in some case: https://github.com/python/cpython/blame/c9dc1f491e8edb0bc433cde73190a3015d226891/Lib/test/test_descr.py#L2548-L2551 But it never does anything if this error is not raised. So, this test can contain a possible problem inside. It will just skip a scenario where `TypeError` is not thrown.

2. The same with `test_file_failt` here: https://github.com/python/cpython/blame/c9dc1f491e8edb0bc433cde73190a3015d226891/Lib/test/test_descr.py#L4451-L4456 If `RuntimeError` is not thrown - nothing happens

3. `assert 0, ...` is problematic: https://github.com/python/cpython/blame/c9dc1f491e8edb0bc433cde73190a3015d226891/Lib/test/test_descr.py#L4451-L4456 It can be dropped in optimized mode and it's error message is not ideal

I will send a PR with all these problems fixed.

----------
components: Tests
messages: 410050
nosy: sobolevn
priority: normal
severity: normal
status: open
title: Improve several exception handling practices in `test_descr.py`
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46299>
_______________________________________


More information about the New-bugs-announce mailing list