➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: Add test.support.check_disallow_instantiation()
类型: enhancement Stage: resolved
Components: Tests Versions: Python 3.11, Python 3.10
process
状态: closed Resolution: fixed
Dependencies: 后续:
分配给: 抄送列表: erlendaasland, miss-islington, vstinner
优先级: normal 关键字: patch

Created on 2021-04-30 14:12 by erlendaasland, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25757 merged erlendaasland, 2021-04-30 16:49
PR 26392 merged erlendaasland, 2021-05-26 22:44
PR 26394 merged erlendaasland, 2021-05-26 22:58
PR 26885 merged erlendaasland, 2021-06-23 21:17
PR 26889 merged erlendaasland, 2021-06-24 07:41
Messages (12)
msg392436 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) 日期: 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) 日期: 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) 日期: 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) 日期: 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.
msg394436 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 2021-05-26 14:15
New changeset 4f725261c6cf23d259e8fdc205e12b76ef4d2d31 by Erlend Egeberg Aasland in branch 'main':
bpo-43988: Add test.support.check_disallow_instantiation() (GH-25757)
https://github.com/python/cpython/commit/4f725261c6cf23d259e8fdc205e12b76ef4d2d31
msg394515 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 2021-05-27 06:44
New changeset fbff5387c3e1f3904420fa5a27738c6c5881305b by Erlend Egeberg Aasland in branch 'main':
bpo-43988: Use check disallow instantiation helper (GH-26392)
https://github.com/python/cpython/commit/fbff5387c3e1f3904420fa5a27738c6c5881305b
msg394537 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 2021-05-27 10:55
New changeset 8cec740820fc875117bfa7b6bdb10202ebeb8fd5 by Erlend Egeberg Aasland in branch 'main':
bpo-43988: Document test.support.check_disallow_instantiation() (GH-26394)
https://github.com/python/cpython/commit/8cec740820fc875117bfa7b6bdb10202ebeb8fd5
msg394538 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) 日期: 2021-05-27 11:12
I believe we can close this now, Victor. Please reopen if you disagree :)
msg394570 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 2021-05-27 17:06
> I believe we can close this now, Victor. Please reopen if you disagree :)

I validated that all tests named "test(...)disallow(...)inst(...)" are now using support.check_disallow_instantiation().

Lib/test/test_tcl.py might use it in:

    @support.cpython_only
    def test_new_tcl_obj(self):
        self.assertRaises(TypeError, _tkinter.Tcl_Obj)
        self.assertRaises(TypeError, _tkinter.TkttType)
        self.assertRaises(TypeError, _tkinter.TkappType)

Serhiy suggested to write an unit test for curses.ncurses_version:
https://bugs.python.org/issue43916#msg391936

This work can be done in bpo-43916.
msg394579 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) 日期: 2021-05-27 17:28
> Lib/test/test_tcl.py might use it [...]

Absolutely.

> Serhiy suggested to write an unit test for curses.ncurses_version:
> https://bugs.python.org/issue43916#msg391936
>
> This work can be done in bpo-43916.

All right.
msg396448 - (view) Author: miss-islington (miss-islington) 日期: 2021-06-23 23:46
New changeset 0a3452e7cf00c51ab1af0f674b670520b09f0e39 by Erlend Egeberg Aasland in branch '3.10':
[3.10] bpo-43988: Add test.support.check_disallow_instantiation() (GH-25757) (GH-26885)
https://github.com/python/cpython/commit/0a3452e7cf00c51ab1af0f674b670520b09f0e39
msg396457 - (view) Author: miss-islington (miss-islington) 日期: 2021-06-24 07:57
New changeset 9049ea51eca081984c8ae37dfeb68b75d624e90d by Erlend Egeberg Aasland in branch 'main':
bpo-43988: Fix test.support.check_disallow_instantiation version added (GH-26889)
https://github.com/python/cpython/commit/9049ea51eca081984c8ae37dfeb68b75d624e90d
历史
日期 用户 动作 参数
2022-04-11 14:59:44admin修改github: 88154
2021-06-24 07:57:30miss-islington修改消息: + msg396457
2021-06-24 07:41:50erlendaasland修改pull_requests: + pull_request25466
2021-06-24 06:51:05vstinner修改状态: open -> closed
resolution: fixed
2021-06-23 23:46:33miss-islington修改抄送: + miss-islington
消息: + msg396448
2021-06-23 22:09:35erlendaasland修改状态: closed -> open
resolution: fixed -> (no value)
versions: + Python 3.10
2021-06-23 21:17:46erlendaasland修改pull_requests: + pull_request25463
2021-05-27 17:28:14erlendaasland修改消息: + msg394579
2021-05-27 17:07:39vstinner修改标题: Add test.support.assert_dissallow_instantiation -> Add test.support.check_disallow_instantiation()
versions: + Python 3.11
2021-05-27 17:06:29vstinner修改消息: + msg394570
2021-05-27 11:12:19erlendaasland修改状态: open -> closed
resolution: fixed
消息: + msg394538

stage: patch review -> resolved
2021-05-27 10:55:58vstinner修改消息: + msg394537
2021-05-27 06:44:01vstinner修改消息: + msg394515
2021-05-26 22:58:23erlendaasland修改pull_requests: + pull_request24987
2021-05-26 22:44:47erlendaasland修改pull_requests: + pull_request24985
2021-05-26 14:15:35vstinner修改消息: + msg394436
2021-04-30 23:04:40vstinner修改消息: + msg392535
2021-04-30 22:39:35erlendaasland修改消息: + msg392525
2021-04-30 22:16:15vstinner修改消息: + msg392518
2021-04-30 16:49:00erlendaasland修改keywords: + patch
stage: patch review
pull_requests: + pull_request24447
2021-04-30 14:12:36erlendaasland修改type: enhancement
2021-04-30 14:12:30erlendaasland创建