classification
Title: `test_functools.TestLRU` must not use `functools` module directly
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, sobolevn
Priority: normal Keywords: patch

Created on 2022-01-14 17:57 by sobolevn, last changed 2022-01-14 21:14 by rhettinger. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30606 merged sobolevn, 2022-01-14 17:58
Messages (2)
msg410579 - (view) Author: Nikita Sobolev (sobolevn) * (Python triager) Date: 2022-01-14 17:57
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
msg410600 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2022-01-14 21:13
New changeset c5640ef87511c960e339af37b486678788be910a by Nikita Sobolev in branch 'main':
bpo-46380: Apply tests to both C and Python version (GH-30606)
https://github.com/python/cpython/commit/c5640ef87511c960e339af37b486678788be910a
History
Date User Action Args
2022-01-14 21:14:23rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-01-14 21:13:54rhettingersetmessages: + msg410600
2022-01-14 20:11:58rhettingersetassignee: rhettinger

nosy: + rhettinger
2022-01-14 17:58:48sobolevnsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28806
2022-01-14 17:57:34sobolevncreate