[New-bugs-announce] [issue40129] Add test classes for custom __index__, __int__, __float__ and __complex__

Serhiy Storchaka report at bugs.python.org
Tue Mar 31 16:37:44 EDT 2020


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

There are many tests for int-like objects (which implement custom __index__ or __int__ methods) in different files. There are less tests for float-like objects (with the __float__ method). There are even tests for complex-like (with the __complex__ method) in different files. To simplify maintaining old tests and adding new tests I propose to add general test classes with custom methods __index__, __int__, __float__ or __complex__ which return the specified value or raise an exception. There is already one similar general class: FakePath.

It could be done using unittest.mock, but Mock objects are much more complex and has too much magic, so they can have different behavior than simpler classes with a single special method.

----------
components: Tests
messages: 365422
nosy: mark.dickinson, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Add test classes for custom __index__, __int__, __float__ and __complex__
type: enhancement
versions: Python 3.9

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


More information about the New-bugs-announce mailing list