[New-bugs-announce] [issue46380] `test_functools.TestLRU` must not use `functools` module directly

Nikita Sobolev report at bugs.python.org
Fri Jan 14 12:57:34 EST 2022


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

Right now there are two tests in Lib/test/test_functools.py that use `functools.lru_cache` directly:
1. https://github.com/python/cpython/blame/73140de97cbeb01bb6c9af1da89ecb9355921e91/Lib/test/test_functools.py#L1417
2. https://github.com/python/cpython/blame/73140de97cbeb01bb6c9af1da89ecb9355921e91/Lib/test/test_functools.py#L1429

But, I don't think it is correct. Why?

```python
class TestLRUPy(TestLRU, unittest.TestCase):
    module = py_functools

class TestLRUC(TestLRU, unittest.TestCase):
    module = c_functools
```

Source: https://github.com/python/cpython/blame/73140de97cbeb01bb6c9af1da89ecb9355921e91/Lib/test/test_functools.py#L1798-L1823

So, what can we do?

1. Use `self.module.lru_cache` instead (I think it is the right way)
2. Move them to `TestLRUPy`, but I don't think they should be python-specific

----------
components: Tests
messages: 410579
nosy: sobolevn
priority: normal
severity: normal
status: open
title: `test_functools.TestLRU`  must not use `functools` module directly
type: behavior
versions: Python 3.11

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


More information about the New-bugs-announce mailing list