Fixes #453 - Reversing behavior of Row.lpush/Row.rpush (#454)

Co-authored-by: chim <chenpan@xiaomai5.com>
This commit is contained in:
Claude Paroz
2020-02-13 19:51:49 +01:00
committed by GitHub
parent f7e39c1ad5
commit 21479001a7
3 changed files with 14 additions and 18 deletions
+8
View File
@@ -1,5 +1,13 @@
# History
## 2.0.0 (Unreleased)
### Breaking changes
- The `Row.lpush/rpush` logic was reversed. `lpush` was appending while `rpush`
and `append` were prepending. This was fixed (reversed behavior). If you
counted on the broken behavior, please update your code (#453).
## 1.1.0 (2020-02-13)
### Deprecations
+2 -2
View File
@@ -71,10 +71,10 @@ class Row:
setattr(self, k, v)
def rpush(self, value):
self.insert(0, value)
self.insert(len(self._row), value)
def lpush(self, value):
self.insert(len(value), value)
self.insert(0, value)
def append(self, value):
self.rpush(value)
+4 -16
View File
@@ -556,27 +556,15 @@ class TablibTestCase(BaseTestCase):
def test_row_lpush(self):
"""Row lpush."""
# Arrange
john = Row(self.john)
george = Row(self.george)
# Act
john.lpush(george)
# Assert
self.assertEqual(john[-1], george)
john.lpush(53)
self.assertEqual(john.list, [53, 'John', 'Adams', 90])
def test_row_append(self):
"""Row append."""
# Arrange
john = Row(self.john)
george = Row(self.george)
# Act
john.append(george)
# Assert
self.assertEqual(john[0], george)
john.append('stuff')
self.assertEqual(john.list, ['John', 'Adams', 90, 'stuff'])
def test_row_contains(self):
"""Row __contains__."""