[issue36871] Misleading error from unittest.mock's assert_has_calls

2019-08-29 Thread Chris Withers
Chris Withers added the comment: New changeset c96127821ebda50760e788b1213975a0d5bea37f by Chris Withers (Xtreak) in branch 'master': bpo-36871: Ensure method signature is used when asserting mock calls to a method (GH13261) https://github.com/python/cpython/commit

[issue36871] Misleading error from unittest.mock's assert_has_calls

2019-08-29 Thread Chris Withers
Chris Withers added the comment: New changeset be310e03d0b84ef56e9d35b0b1b21d685b7ea371 by Chris Withers (Miss Islington (bot)) in branch '3.7': bpo-36871: Ensure method signature is used when asserting mock calls to a method (GH15577) https://github.com/python/cpython/commit

[issue36871] Misleading error from unittest.mock's assert_has_calls

2019-08-29 Thread Chris Withers
Chris Withers added the comment: New changeset 38d311d79e57479f7a684c2cd298293033dc4990 by Chris Withers (Miss Islington (bot)) in branch '3.8': bpo-36871: Ensure method signature is used when asserting mock calls to a method (GH15578) https://github.com/python/cpython/commit

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread Chris Withers
Chris Withers added the comment: New changeset 7397cda99795a4a8d96193d710105e77a07b7411 by Chris Withers (Xtreak) in branch 'master': bpo-21478: Record calls to parent when autospecced objects are used as child with attach_mock (GH 14688) https://github.com/python/cpython/commit

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread Chris Withers
Chris Withers added the comment: New changeset 22fd679dc363bfcbda336775da16aff4d6fcb33f by Chris Withers (Miss Islington (bot)) in branch '3.8': bpo-21478: Record calls to parent when autospecced objects are used as child with attach_mock (GH 14688) (GH-14902) https://github.com/python

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread Chris Withers
Chris Withers added the comment: New changeset e9b187a2bfbb0586fc5d554ce745b7fe04e0b9a8 by Chris Withers (Miss Islington (bot)) in branch '3.7': bpo-21478: Record calls to parent when autospecced objects are used as child with attach_mock (GH 14688) (GH-14903) https://github.com/python

[issue38757] mocking an exception, arguments do not seem to be passed to the mock

2019-11-11 Thread Chris Withers
Chris Withers added the comment: Agreed. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue38763] mock with side effect : assert_called_once returns None while call_count returns 1

2019-11-12 Thread Chris Withers
Change by Chris Withers : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue38763> ___ ___

[issue30463] Add __slots__ to ABC convenience class

2019-11-15 Thread Chris Withers
Chris Withers added the comment: I will note that this means with: class BaseClass(ABC): pass class MyDerivedClass(BaseClass): def __init__(self, thing): self.thing = thing thing = MyDerivedClass() thing now has both __slots__ and, evidently, a dict. That's a bit weird

[issue38757] mocking an exception, arguments do not seem to be passed to the mock

2019-11-09 Thread Chris Withers
Chris Withers added the comment: Not sure this is correct, if an effect is an exception and requires args, then it should be passed as an instance, not a class: Mock(side_effect=MyException(‘foo’)) > On 10 Nov 2019, at 04:49, Karthikeyan Singaravelan > wrote: > > &

[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread Chris Withers
Chris Withers added the comment: New changeset 41973c99fdfdc78315e819661e279bdcc2f058b1 by Chris Withers (Miss Islington (bot)) in branch '3.7': bpo-38669: patch.object now raises a helpful error (GH17511) https://github.com/python/cpython/commit/41973c99fdfdc78315e819661e279bdcc2f058b1

[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread Chris Withers
Chris Withers added the comment: New changeset 4594565b56e9c99d2d3fb7549041bbca5ecba8e2 by Chris Withers (Miss Islington (bot)) in branch '3.8': bpo-38669: patch.object now raises a helpful error (GH17510) https://github.com/python/cpython/commit/4594565b56e9c99d2d3fb7549041bbca5ecba8e2

[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread Chris Withers
Change by Chris Withers : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue38669] patch.object should raise another error when first argument is a str

2019-12-08 Thread Chris Withers
Chris Withers added the comment: New changeset cd90a52983db34896a6335a572d55bdda274778f by Chris Withers (Elena Oat) in branch 'master': bpo-38669: patch.object now raises a helpful error (GH17034) https://github.com/python/cpython/commit/cd90a52983db34896a6335a572d55bdda274778f

[issue39753] inspecting a partial with bound keywods gives incorrect signature

2020-02-25 Thread Chris Withers
Chris Withers added the comment: Surprised partials have no explicit signature: >>> p.__signature__ Traceback (most recent call last): File "", line 1, in AttributeError: 'functools.partial' object has no attribute '__signature__' -- ___

[issue39753] inspecting a partial with bound keywods gives incorrect signature

2020-02-25 Thread Chris Withers
Change by Chris Withers : -- components: +Library (Lib) versions: +Python 3.8 ___ Python tracker <https://bugs.python.org/issue39753> ___ ___ Python-bugs-list m

[issue39753] inspecting a partial with bound keywods gives incorrect signature

2020-02-25 Thread Chris Withers
New submission from Chris Withers : $ python Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from functools import part

[issue39753] inspecting a partial with bound keywords gives incorrect signature

2020-03-01 Thread Chris Withers
Chris Withers added the comment: Not sure I understand your comment. The results of calling inpsect on a partial with bound keyword parameters are incorrect. Furthermore, it is surprisingly that partial objects don't maintain their own __signature__. What is it you're suggesting

[issue21600] mock.patch.stopall doesn't work with patch.dict

2020-01-24 Thread Chris Withers
Change by Chris Withers : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue37669] Make mock_open return per-file content

2020-01-24 Thread Chris Withers
Chris Withers added the comment: I'm not sure I like the API feel after this change: two parameters that can't be used at the same time. As Karthikeyan points out, this can be achieved using side_effect. Personally, I'd prefer a PR that adds a unit test showing that this approach works

[issue24928] mock.patch.dict spoils order of items in collections.OrderedDict

2020-01-24 Thread Chris Withers
Chris Withers added the comment: New changeset 1d0c5e16eab29d55773cc4196bb90d2bf12e09dd by Chris Withers (Emmanuel Arias) in branch 'master': bpo-24928: Add test case for patch.dict using OrderedDict (GH -11437) https://github.com/python/cpython/commit

[issue37669] Make mock_open return per-file content

2020-01-24 Thread Chris Withers
Chris Withers added the comment: Closing in favour of issue38157. -- resolution: -> duplicate stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue24928] mock.patch.dict spoils order of items in collections.OrderedDict

2020-01-24 Thread Chris Withers
Chris Withers added the comment: As I said before, I can't see an additional test like this hurting, especially if it highlights problems with earlier python versions when it's backported. -- ___ Python tracker <https://bugs.python.org/issue24

[issue38473] AttributeError on asserting autospecced mock object added using attach_mock

2020-01-24 Thread Chris Withers
Chris Withers added the comment: New changeset 66b00a9d3aacf6ed49412f48743e4913104a2bb3 by Chris Withers (Karthikeyan Singaravelan) in branch 'master': bpo-38473: Handle autospecced functions and methods used with attach_mock (GH-16784) https://github.com/python/cpython/commit

[issue39082] AsyncMock is unable to correctly patch static or class methods

2020-01-26 Thread Chris Withers
Chris Withers added the comment: New changeset 19be85c76503535c101b38194d282187de0ff631 by Chris Withers (Matthew Kokotovich) in branch '3.8': [3.8] bpo-39082: Allow AsyncMock to correctly patch static/class methods (GH-18190) https://github.com/python/cpython/commit

[issue25597] unittest.mock does not wrap dunder methods (__getitem__ etc)

2020-01-26 Thread Chris Withers
Chris Withers added the comment: New changeset 72b1004657e60c900e4cd031b2635b587f4b280e by Chris Withers (Karthikeyan Singaravelan) in branch 'master': bpo-25597: Ensure wraps' return value is used for magic methods in MagicMock (#16029) https://github.com/python/cpython/commit

[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers
Chris Withers added the comment: New changeset a327677905956ae0b239ff430a1346dfe265709e by Carl Friedrich Bolz-Tereick in branch 'master': bpo-39485: fix corner-case in method-detection of mock (GH-18252) https://github.com/python/cpython/commit/a327677905956ae0b239ff430a1346dfe265709e

[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers
Change by Chris Withers : -- assignee: -> cjw296 ___ Python tracker <https://bugs.python.org/issue39485> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2020-01-29 Thread Chris Withers
Chris Withers added the comment: New changeset db5e86adbce12350c26e7ffc2c6673369971a2dc by Chris Withers in branch 'master': Get mock coverage back to 100% (GH-18228) https://github.com/python/cpython/commit/db5e86adbce12350c26e7ffc2c6673369971a2dc

[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers
Chris Withers added the comment: Thank you very much for this, that was a really good catch! -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers
Chris Withers added the comment: New changeset cf0645a17acbc0c4dbbf82434e37637965748bbb by Miss Islington (bot) in branch '3.7': bpo-39485: fix corner-case in method-detection of mock (GH-18256) https://github.com/python/cpython/commit/cf0645a17acbc0c4dbbf82434e37637965748bbb

[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers
Chris Withers added the comment: New changeset 696d2324cf2a54e20e8d6a6739fa97ba815a8be9 by Miss Islington (bot) in branch '3.8': bpo-39485: fix corner-case in method-detection of mock (GH-18255) https://github.com/python/cpython/commit/696d2324cf2a54e20e8d6a6739fa97ba815a8be9

[issue39551] mock patch should match behavior of import from when module isn't present in sys.modules

2020-02-04 Thread Chris Withers
Chris Withers added the comment: I'm afraid I don't understand "immutable package which doesn't allow it's children to be published on it", can you give an example? -- ___ Python tracker <https://bugs.python.o

[issue39551] mock patch should match behavior of import from when module isn't present in sys.modules

2020-02-04 Thread Chris Withers
Chris Withers added the comment: What's the real world use case for this? -- nosy: +cjw296 ___ Python tracker <https://bugs.python.org/issue39551> ___ ___ Pytho

[issue39551] mock patch should match behavior of import from when module isn't present in sys.modules

2020-02-06 Thread Chris Withers
Chris Withers added the comment: Apologies, but I'm still not sure what "the modules are published" means? "publish "x" as a child onto the package" also doesn't mean much to me, I'm afraid. Are you aware of any importlib docs or some such which might be able

[issue39450] unittest TestCase shortDescription does not strip whitespace

2020-02-02 Thread Chris Withers
Chris Withers added the comment: New changeset 032de7324e30c6b44ef272cea3be205a3d768759 by Steve Cirelli in branch 'master': bpo-39450 Stripped whitespace before parsing the docstring in TestCase.shortDescription (GH-18175) https://github.com/python/cpython/commit

[issue39450] unittest TestCase shortDescription does not strip whitespace

2020-02-02 Thread Chris Withers
Chris Withers added the comment: New changeset 7561e7a83f5118fda6c62fe9c8c3458f8cfd by Miss Islington (bot) in branch '3.7': bpo-39450 Stripped whitespace before parsing the docstring in TestCase.shortDescription (GH-18321) https://github.com/python/cpython/commit

[issue39450] unittest TestCase shortDescription does not strip whitespace

2020-02-03 Thread Chris Withers
Chris Withers added the comment: New changeset 02395fad8e3a35ef00fa31c308693844013a1dd4 by Miss Islington (bot) in branch '3.8': bpo-39450 Stripped whitespace before parsing the docstring in TestCase.shortDescription (GH-18175) (#18323) https://github.com/python/cpython/commit

[issue31826] Misleading __version__ attribute of modules in standard library

2020-02-04 Thread Chris Withers
Change by Chris Withers : -- keywords: +patch pull_requests: +17717 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17977 ___ Python tracker <https://bugs.python.org/issu

[issue37955] mock.patch incorrect reference to Mock

2020-01-25 Thread Chris Withers
Change by Chris Withers : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue39082] AsyncMock is unable to correctly patch static or class methods

2020-01-25 Thread Chris Withers
Chris Withers added the comment: New changeset 62865f4532094017a9b780b704686ca9734bc329 by Chris Withers (Matthew Kokotovich) in branch 'master': bpo-39082: Allow AsyncMock to correctly patch static/class methods (GH-18116) https://github.com/python/cpython/commit

[issue39082] AsyncMock is unable to correctly patch static or class methods

2020-01-25 Thread Chris Withers
Change by Chris Withers : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue37955] mock.patch incorrect reference to Mock

2020-01-25 Thread Chris Withers
Chris Withers added the comment: New changeset 40c080934b3d49311209b1cb690c2ea1e04df7e7 by Chris Withers (Paulo Henrique Silva) in branch 'master': bpo-37955: correct mock.patch docs with respect to the returned type (GH-15521) https://github.com/python/cpython/commit

[issue38932] unittest.mock.Mock.reset_mocks does not pass all arguments to its children

2020-01-25 Thread Chris Withers
Change by Chris Withers : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue38932] unittest.mock.Mock.reset_mocks does not pass all arguments to its children

2020-01-25 Thread Chris Withers
Chris Withers added the comment: New changeset aef7dc89879d099dc704bd8037b8a7686fb72838 by Chris Withers (Vegard Stikbakke) in branch 'master': bpo-38932: Mock fully resets child objects on reset_mock(). (GH-17409) https://github.com/python/cpython/commit

[issue39551] mock patch should match behavior of import from when module isn't present in sys.modules

2020-02-09 Thread Chris Withers
Chris Withers added the comment: Hmm, the more we get into this, the less comfortable I am of the patch in the PR. Instead of copying and pasting more code that's likely to get out of sync, could you change the PR to just replace _importer with the correct parts of importlib to support

[issue39222] unittest.mock.Mock.parent is broken or undocumented

2020-01-12 Thread Chris Withers
Chris Withers added the comment: Ah right. Well, it's called `parent` in the __init__ as that's what the attribute used to be called. My suggestion would be to add `parent` to the docs @xtreak links to as a way to resolve this issue

[issue39222] unittest.mock.Mock.parent is broken or undocumented

2020-01-10 Thread Chris Withers
Chris Withers added the comment: I thought we'd already changed this to _mock_parent in the last year or so? -- ___ Python tracker <https://bugs.python.org/issue39

[issue39915] await_args_list in AsyncMock always refers to the last awaited call object

2020-03-11 Thread Chris Withers
Chris Withers added the comment: New changeset e553f204bf0e39b1d701a364bc71b286acb9433f by Karthikeyan Singaravelan in branch 'master': bpo-39915: Ensure await_args_list is updated according to the order in which coroutines were awaited (GH-18924) https://github.com/python/cpython/commit

[issue39915] await_args_list in AsyncMock always refers to the last awaited call object

2020-03-14 Thread Chris Withers
Chris Withers added the comment: New changeset f6bdac1bf718eab0cc5b6554f363f21252d245ce by Miss Islington (bot) in branch '3.8': bpo-39915: Ensure await_args_list is updated according to the order in which coroutines were awaited (GH-18927) https://github.com/python/cpython/commit

[issue40133] Provide additional matchers for unittest.mock

2020-04-16 Thread Chris Withers
Chris Withers added the comment: Agreed, this would be better placed in a third party library. There's examples out there already, for example, I maintain a library [0] that has tools for asserting about complex data structures, including flexible type matching [1] and regex string matching

[issue25597] unittest.mock does not wrap dunder methods (__getitem__ etc)

2020-04-28 Thread Chris Withers
Chris Withers added the comment: New changeset 521c8d6806adf0305c158d280ec00cca48e8ab22 by Karthikeyan Singaravelan in branch 'master': bpo-39966: Revert "bpo-25597: Ensure wraps' return value is used for magic methods in MagicMock" (GH-19734) https://github.com/python/cpyt

[issue39966] mock 3.9 bug: Wrapped objects without __bool__ raise exception

2020-04-28 Thread Chris Withers
Chris Withers added the comment: New changeset 521c8d6806adf0305c158d280ec00cca48e8ab22 by Karthikeyan Singaravelan in branch 'master': bpo-39966: Revert "bpo-25597: Ensure wraps' return value is used for magic methods in MagicMock" (GH-19734) https://github.com/python/cpyt

[issue39966] mock 3.9 bug: Wrapped objects without __bool__ raise exception

2020-04-27 Thread Chris Withers
Chris Withers added the comment: I'd go with your instincts on what to do next, I'd have a slight preference to keeping behaviour the same as it was in 3.8 if the changes for 3.9 cause more problems. That leaves us no worse off than we were before, and with the opportunity to improve from

[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Chris Withers
Chris Withers added the comment: The tough one is that no-one wants an ugly sys._getframe() call, but by avoiding it in the standard library, we force each library that needs this to have the ugly sys._getframe() call rather than it being an unpleasant implementation detail

[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Chris Withers
New submission from Chris Withers : Reproducer: def test_forward_type_references(self): def foo(a: 'Foo') -> 'Bar': pass class Foo: pass class Bar: pass get_type_hints(foo) The above gives the following exception, rather than resolving the t

[issue40133] Provide additional matchers for unittest.mock

2020-06-18 Thread Chris Withers
Chris Withers added the comment: Gregory, I find your response a little troubling. Myself and Karthikeyan both do a lot of work on Mock, some might even say we're the maintainers of Mock in both cpython's core repo and the backport. We both feel this belongs standalone on pypi, and would

[issue40133] Provide additional matchers for unittest.mock

2020-06-23 Thread Chris Withers
Chris Withers added the comment: Okay, but to be up-front about this, I don't see any place in the stdlib for any more "helpers" that could more easily be maintained on pypi and wouldn't incur further support burden for anyone looking after this part of the standard library.

[issue40805] Can no longer patch flask.g

2020-06-03 Thread Chris Withers
Change by Chris Withers : -- status: closed -> open ___ Python tracker <https://bugs.python.org/issue40805> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue40805] Can no longer patch flask.g

2020-06-03 Thread Chris Withers
Chris Withers added the comment: Rob, you're welcome to dump `mock` and use `unittest.mock`, and that might be best for now, but this will then likely come back to bite you when you end up on the version of Python, probably 3.9, where it is present

[issue40805] Can no longer patch flask.g

2020-06-03 Thread Chris Withers
Chris Withers added the comment: Terry, mock is now a rolling backport of unittest.mock with all development taking place in cpython's repo. If issues are reported there, they need to be triaged here first, as it's most likely a bug in unittest.mock that needs fixing here. Rob, please can

[issue41403] Uncaught AttributeError in unittest.mock._get_target

2020-07-27 Thread Chris Withers
Chris Withers added the comment: Given that `mock.patch` is being used incorrectly here, the error message seems clear enough: It's saying there's a `Foo` object in place, and `rsplit` gives a strong indication that a string was expected. Would adding type hints in mock.py be a resolution

[issue42532] spec_arg's __bool__ is called while initializing NonCallableMock

2020-12-06 Thread Chris Withers
Chris Withers added the comment: New changeset c598a04dd29b89ad072245ddaf738badcfb41ac7 by idanw206 in branch 'master': bpo-42532: Check if NonCallableMock's spec_arg is not None instead of call its __bool__ function (GH23613) https://github.com/python/cpython/commit

[issue3722] print followed by exception eats print with doctest

2020-12-20 Thread Chris Withers
Change by Chris Withers : -- keywords: -easy ___ Python tracker <https://bugs.python.org/issue3722> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue3722] print followed by exception eats print with doctest

2020-12-20 Thread Chris Withers
Chris Withers added the comment: @iritkatriel - if Tim thinks this is hard, it probably is hard ;-) -- ___ Python tracker <https://bugs.python.org/issue3

[issue44534] unittest.mock.Mock.unsafe doc is garbled

2021-07-05 Thread Chris Withers
Chris Withers added the comment: New changeset abb08e3af6aa19928007a349592e95e6de38467f by Jack DeVries in branch 'main': bpo-44534: fix wording and docstring sync in unittest.Mock GH27000 https://github.com/python/cpython/commit/abb08e3af6aa19928007a349592e95e6de38467f -- nosy

[issue43478] Disallow Mock spec arguments from being Mocks

2021-03-15 Thread Chris Withers
Chris Withers added the comment: I agree that this should raise an exception. Can the two failing tests in mock's own suite be easily fixed? -- ___ Python tracker <https://bugs.python.org/issue43

<    1   2   3   4   5   6