[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2019-01-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2019-01-21 Thread Chris Withers


Chris Withers  added the comment:


New changeset d358a8cda75446a8e0b5d99149f709395d5eae19 by Chris Withers (Miss 
Islington (bot)) in branch '3.7':
bpo-20239: Allow repeated deletion of unittest.mock.Mock attributes (GH-11629)
https://github.com/python/cpython/commit/d358a8cda75446a8e0b5d99149f709395d5eae19


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2019-01-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +11395, 11396, 11397

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2019-01-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +11395, 11396

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2019-01-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +11395

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2019-01-21 Thread Chris Withers


Chris Withers  added the comment:


New changeset 222d303ade8aadf0adcae5190fac603bdcafe3f0 by Chris Withers (Pablo 
Galindo) in branch 'master':
bpo-20239: Allow repeated deletion of unittest.mock.Mock attributes (#11057)
https://github.com/python/cpython/commit/222d303ade8aadf0adcae5190fac603bdcafe3f0


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2018-12-09 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +patch
pull_requests: +10291
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2018-12-09 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I find this to be a reasonable behavior as with normal objects that support 
setting the attribute after deletion. It also seems to be an easy issue since 
@michael.foord has already attached the patch for this from the original 
report. The patch also also causes no test failure on master and a unit test 
can be added for the behavior once confirmed.

--
nosy: +cjw296, mariocj89, xtreak
versions: +Python 3.7, Python 3.8 -Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20239] Allow repeated deletion of unittest.mock.Mock attributes

2014-01-13 Thread Michael Foord

New submission from Michael Foord:

Reported as mock issue 221: http://code.google.com/p/mock/issues/detail?id=221

 from unittest.mock import Mock
 m = Mock()
 m.foo = 3
 del m.foo
 m.foo = 4
 del m.foo
Traceback (most recent call last):
  File stdin, line 1, in module
  File /compile/py3k-cpython/Lib/unittest/mock.py, line 687, in __delattr__
raise AttributeError(name)
AttributeError: foo

Suggested change:

Previous:

   def __delattr__(self, name):
   if name in _all_magics and name in type(self).__dict__:
   delattr(type(self), name)
   if name not in self.__dict__:
   # for magic methods that are still MagicProxy objects and
   # not set on the instance itself
   return

   if name in self.__dict__:
   object.__delattr__(self, name)

   obj = self._mock_children.get(name, _missing)
   if obj is _deleted:
   raise AttributeError(name)
   if obj is not _missing:
   del self._mock_children[name]
   self._mock_children[name] = _deleted


Change:

   def __delattr__(self, name):
   if name in _all_magics and name in type(self).__dict__:
   delattr(type(self), name)
   if name not in self.__dict__:
   # for magic methods that are still MagicProxy objects and
   # not set on the instance itself
   return

   obj = self._mock_children.get(name, _missing)
   if name in self.__dict__:
   object.__delattr__(self, name)
   elif obj is _deleted:
   raise AttributeError(name)
   if obj is not _missing:
   del self._mock_children[name]
   self._mock_children[name] = _deleted


Incidentally the if ‘obj is not _missing’ line seems superfluous.

--
assignee: michael.foord
messages: 208019
nosy: michael.foord
priority: normal
severity: normal
stage: needs patch
status: open
title: Allow repeated deletion of unittest.mock.Mock attributes
type: behavior
versions: Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20239
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com