Skip to content

Commit

Permalink
Merge 70f7e29 into 9d2cc06
Browse files Browse the repository at this point in the history
  • Loading branch information
lungj committed Jul 19, 2019
2 parents 9d2cc06 + 70f7e29 commit cc31ccd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions persistent/list.py
Expand Up @@ -72,6 +72,13 @@ def append(self, item):
self.__super_append(item)
self._p_changed = 1

if not PYTHON2:
__super_clear = UserList.clear

def clear(self):
self.__super_clear()
self._p_changed = 1

def insert(self, i, item):
self.__super_insert(i, item)
self._p_changed = 1
Expand Down
11 changes: 11 additions & 0 deletions persistent/tests/test_list.py
Expand Up @@ -303,6 +303,17 @@ def test_append(self):
self.assertEqual(inst, [1])
self.assertTrue(inst._p_changed)

def test_clear(self):
# The clear method is not part of Python 2.
from persistent._compat import PYTHON2
if not PYTHON2:
inst = self._makeOne([1])
self.assertFalse(inst._p_changed)
inst.clear()
self.assertEqual(inst, [])
self.assertTrue(inst._p_changed)


def test_insert(self):
inst = self._makeOne()
self.assertFalse(inst._p_changed)
Expand Down

0 comments on commit cc31ccd

Please sign in to comment.