Re: [Python-Dev] [Python-checkins] cpython (3.3): Process DEFAULT values in mock side_effect that returns iterator.

2013-04-09 Thread Andrew Svetlov
My bad, sorry

On Mon, Apr 8, 2013 at 8:03 PM, Antoine Pitrou solip...@pitrou.net wrote:
 On Mon, 8 Apr 2013 10:52:30 +0100
 Michael Foord fuzzy...@gmail.com wrote:
 On 7 April 2013 14:44, andrew.svetlov python-check...@python.org wrote:

  http://hg.python.org/cpython/rev/18fd64f1de2d
  changeset:   83179:18fd64f1de2d
  branch:  3.3
  user:Andrew Svetlov andrew.svet...@gmail.com
  date:Sun Apr 07 16:42:24 2013 +0300
  summary:
Process DEFAULT values in mock side_effect that returns iterator.
 
  Patch by Michael Ford.
 
 [...]

 This was committed without a NEWS entry.

 And I wonder who that Michael Ford is :-)

 Regards

 Antoine.


 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe: 
 http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com



-- 
Thanks,
Andrew Svetlov
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] cpython (3.3): Process DEFAULT values in mock side_effect that returns iterator.

2013-04-08 Thread Michael Foord
On 7 April 2013 14:44, andrew.svetlov python-check...@python.org wrote:

 http://hg.python.org/cpython/rev/18fd64f1de2d
 changeset:   83179:18fd64f1de2d
 branch:  3.3
 user:Andrew Svetlov andrew.svet...@gmail.com
 date:Sun Apr 07 16:42:24 2013 +0300
 summary:
   Process DEFAULT values in mock side_effect that returns iterator.

 Patch by Michael Ford.

 files:
   Lib/unittest/mock.py   |  2 ++
   Lib/unittest/test/testmock/testmock.py |  4 
   2 files changed, 6 insertions(+), 0 deletions(-)


 diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
 --- a/Lib/unittest/mock.py
 +++ b/Lib/unittest/mock.py
 @@ -904,6 +904,8 @@
  result = next(effect)
  if _is_exception(result):
  raise result
 +if result is DEFAULT:
 +result = self.return_value
  return result

  ret_val = effect(*args, **kwargs)
 diff --git a/Lib/unittest/test/testmock/testmock.py
 b/Lib/unittest/test/testmock/testmock.py
 --- a/Lib/unittest/test/testmock/testmock.py
 +++ b/Lib/unittest/test/testmock/testmock.py
 @@ -906,6 +906,10 @@
  self.assertRaises(StopIteration, mock)
  self.assertIs(mock.side_effect, this_iter)

 +def test_side_effect_iterator_default(self):
 +mock = Mock(return_value=2)
 +mock.side_effect = iter([1, DEFAULT])
 +self.assertEqual([mock(), mock()], [1, 2])

  def test_assert_has_calls_any_order(self):
  mock = Mock()

 --
 Repository URL: http://hg.python.org/cpython



This was committed without a NEWS entry.

Michael



 ___
 Python-checkins mailing list
 python-check...@python.org
 http://mail.python.org/mailman/listinfo/python-checkins




-- 

http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] cpython (3.3): Process DEFAULT values in mock side_effect that returns iterator.

2013-04-08 Thread Antoine Pitrou
On Mon, 8 Apr 2013 10:52:30 +0100
Michael Foord fuzzy...@gmail.com wrote:
 On 7 April 2013 14:44, andrew.svetlov python-check...@python.org wrote:
 
  http://hg.python.org/cpython/rev/18fd64f1de2d
  changeset:   83179:18fd64f1de2d
  branch:  3.3
  user:Andrew Svetlov andrew.svet...@gmail.com
  date:Sun Apr 07 16:42:24 2013 +0300
  summary:
Process DEFAULT values in mock side_effect that returns iterator.
 
  Patch by Michael Ford.
 
[...]
 
 This was committed without a NEWS entry.

And I wonder who that Michael Ford is :-)

Regards

Antoine.


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com