classification
Title: Add test.support.assert_dissallow_instantiation
Type: enhancement Stage: patch review
Components: Tests Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: erlendaasland, vstinner
Priority: normal Keywords: patch

Created on 2021-04-30 14:12 by erlendaasland, last changed 2021-04-30 23:04 by vstinner.

Pull Requests
URL Status Linked Edit
PR 25757 open erlendaasland, 2021-04-30 16:49
Messages (4)
msg392436 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-04-30 14:12
See https://github.com/python/cpython/pull/25748#discussion_r623849521:
"What do you think of adding support.assert_disallow_instanciation(type, *args) function which would check for TypeError but also check the error message? TypeError is quite generic and it might hide a bug."


Ref. bpo-43916.
msg392518 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-30 22:16
You can take this issue as an opportunity to fix my typo :-)

Lib/test/test_hashlib.py: "test_disallow_instanciation" => "test_disallow_instantiation".
https://github.com/python/cpython/commit/665c7746fca180266b121183c2d5136c547006e0#commitcomment-50235589

There are now many tests:

Lib/test/test_array.py:    def test_disallow_instantiation(self):
Lib/test/test_curses.py:    def test_disallow_instantiation(self):
Lib/test/test_dbm_gnu.py:    def test_disallow_instantiation(self):
Lib/test/test_embed.py:    def test_disallow_instantiation(self):
Lib/test/test_functools.py:    def test_disallow_instantiation(self):
Lib/test/test_hashlib.py:    def test_disallow_instanciation(self):
Lib/test/test_hashlib.py:    def test_hash_disallow_instanciation(self):
Lib/test/test_re.py:    def test_disallow_instantiation(self):
Lib/test/test_select.py:    def test_disallow_instantiation(self):
Lib/test/test_threading.py:    def test_disallow_instantiation(self):
Lib/test/test_unicodedata.py:    def test_disallow_instantiation(self):
Lib/test/test_zlib.py:    def test_disallow_instantiation(self):
msg392525 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-04-30 22:39
I'll fix your typo ;) I'll include the rest of the test in the PR. I just pushed it out quickly to get a review of the solution.
msg392535 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-30 23:04
You can keep PR 25757 to add the helper function, and then write a second PR to use it in all tests.
History
Date User Action Args
2021-04-30 23:04:40vstinnersetmessages: + msg392535
2021-04-30 22:39:35erlendaaslandsetmessages: + msg392525
2021-04-30 22:16:15vstinnersetmessages: + msg392518
2021-04-30 16:49:00erlendaaslandsetkeywords: + patch
stage: patch review
pull_requests: + pull_request24447
2021-04-30 14:12:36erlendaaslandsettype: enhancement
2021-04-30 14:12:30erlendaaslandcreate