New submission from Václav Brožek <v...@google.com>:

Recently we cleaned up the following typos in mocks in unittests of our 
codebase:

* Wrong prefixes of mock asserts: asert/aseert/assrt -> assert
* Wrong attribute names around asserts: autospect/auto_spec -> autospec, 
set_spec -> spec_set

Especially the asserts are dangerous, because a misspelled assert_called will 
fail silently. We found real bugs in production code which were masked by a 
misspelled assert_called.

There is prior work done to report similar cases of assert misspellings with an 
AttributeError: 
https://github.com/testing-cabal/mock/commit/7c530f0d9aa48d2538501761098df7a5a8979a7d,
 and adding new cases will be an easy change. I suppose that adding similar 
error signalling for the wrong argument names will not be much harder.

I'm prepared to implement it, if people of this project would be happy to have 
such checks.

----------
components: Library (Lib)
messages: 377611
nosy: vabr2
priority: normal
severity: normal
status: open
title: Check against misspellings of assert etc. in mock
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41877>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to