[issue28919] Simplify `_copy_func_details` in unittest.mock
Changes by Jiajun Huang : -- components: Library (Lib) files: mock.patch keywords: patch nosy: Jiajun Huang priority: normal pull_requests: 2 severity: normal status: open title: Simplify `_copy_func_details` in unittest.mock type: enhancement versions: Python 3.7 Added file: http://bugs.python.org/file45811/mock.patch ___ Python tracker <http://bugs.python.org/issue28919> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28919] Simplify `_copy_func_details` in unittest.mock
Jiajun Huang added the comment: So what should I do next to make the code being merged into CPython? I am new to mercurial(or just wait for it?). -- ___ Python tracker <http://bugs.python.org/issue28919> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28961] Is it a bug(method `_Call.__new__` in unittest.mock)?
New submission from Jiajun Huang: code in `_Call.__new__`: def __new__(cls, value=(), name=None, parent=None, two=False, ¦ ¦ ¦ from_kall=True): ¦ name = '' ¦ args = () ¦ kwargs = {} ¦ _len = len(value) ¦ if _len == 3: ... the parameter `name` had been override since the function starts. so whatever name is, it's been ignored. Is it a bug? or something else? -- components: Library (Lib) messages: 283104 nosy: Jiajun Huang priority: normal severity: normal status: open title: Is it a bug(method `_Call.__new__` in unittest.mock)? type: enhancement versions: Python 3.7 ___ Python tracker <http://bugs.python.org/issue28961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28961] unittest.mock._Call ignores `name` parameter
Jiajun Huang added the comment: Thanks for reply :) the patch has been uploaded. -- keywords: +patch Added file: http://bugs.python.org/file45883/mock_class_call.patch ___ Python tracker <http://bugs.python.org/issue28961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28961] unittest.mock._Call ignores `name` parameter
Jiajun Huang added the comment: update the patch file follow the doc(https://docs.python.org/devguide/gitdevs.html) -- Added file: http://bugs.python.org/file45884/mock.patch ___ Python tracker <http://bugs.python.org/issue28961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28961] unittest.mock._Call ignores `name` parameter
Jiajun Huang added the comment: The new patch has been updated. :) -- Added file: http://bugs.python.org/file45885/mock.patch ___ Python tracker <http://bugs.python.org/issue28961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28961] unittest.mock._Call ignores `name` parameter
Jiajun Huang added the comment: I think we can write `_Call.__new__` as: def __new__(cls, value=(), name='',...) it's much simpler and readable. -- ___ Python tracker <http://bugs.python.org/issue28961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28961] unittest.mock._Call ignores `name` parameter
Jiajun Huang added the comment: code and test case has been updated. -- Added file: http://bugs.python.org/file45922/mock.patch ___ Python tracker <http://bugs.python.org/issue28961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28961] unittest.mock._Call ignores `name` parameter
Jiajun Huang added the comment: hi, do this need more test case or something else to be merged? please let me know :) -- ___ Python tracker <http://bugs.python.org/issue28961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28961] unittest.mock._Call ignores `name` parameter
Jiajun Huang added the comment: sorry about that, fixed. -- Added file: http://bugs.python.org/file46126/mock.patch ___ Python tracker <http://bugs.python.org/issue28961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29200] is it a bug in `functools._HashedSeq`
New submission from Jiajun Huang: the class definition: class _HashedSeq(list): """ This class guarantees that hash() will be called no more than once per element. This is important because the lru_cache() will hash the key multiple times on a cache miss. """ __slots__ = 'hashvalue' def __init__(self, tup, hash=hash): self[:] = tup self.hashvalue = hash(tup) def __hash__(self): return self.hashvalue and I've test for it: In [1]: from functools import _HashedSeq In [2]: from unittest.mock import Mock In [3]: test_tup = 1, 2, 3, "hello", "world" In [4]: hash_func = Mock() In [5]: _HashedSeq(test_tup, hash=hash_func) Out[5]: [1, 2, 3, 'hello', 'world'] In [6]: _HashedSeq(test_tup, hash=hash_func) Out[6]: [1, 2, 3, 'hello', 'world'] In [7]: _HashedSeq(test_tup, hash=hash_func) Out[7]: [1, 2, 3, 'hello', 'world'] In [8]: hash_func.call_count Out[8]: 3 the hash function had been called 3 times rather than 1. -- components: Library (Lib) messages: 284949 nosy: Jiajun Huang priority: normal severity: normal status: open title: is it a bug in `functools._HashedSeq` versions: Python 3.7 ___ Python tracker <http://bugs.python.org/issue29200> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29200] is it a bug in `functools._HashedSeq`
Jiajun Huang added the comment: thanks for reply :) 2017年1月8日星期日,Roundup Robot 写道: > > Roundup Robot added the comment: > > New changeset 2e7e91785306 by Raymond Hettinger in branch 'default': > Issue #29200: Fix test to use self.assertEqual instead of py.test style > tests > https://hg.python.org/cpython/rev/2e7e91785306 > > -- > > ___ > Python tracker > > <http://bugs.python.org/issue29200> > ___ > -- ___ Python tracker <http://bugs.python.org/issue29200> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com