summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2020-02-13 19:51:49 +0100
committerGitHub <noreply@github.com>2020-02-13 20:51:49 +0200
commit21479001a71864d44e95825b86bc6e432de40f58 (patch)
tree785cddf6123b2c41b2c5cdf885b5e612a7956ca4
parentf7e39c1ad5fb20b125f23cfa8766cc1f308591eb (diff)
downloadtablib-21479001a71864d44e95825b86bc6e432de40f58.tar.gz
Fixes #453 - Reversing behavior of Row.lpush/Row.rpush (#454)
Co-authored-by: chim <chenpan@xiaomai5.com>
-rw-r--r--HISTORY.md8
-rw-r--r--src/tablib/core.py4
-rwxr-xr-xtests/test_tablib.py20
3 files changed, 14 insertions, 18 deletions
diff --git a/HISTORY.md b/HISTORY.md
index 21647dc..c6c6c72 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -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
diff --git a/src/tablib/core.py b/src/tablib/core.py
index 73cc8e6..4fbe76a 100644
--- a/src/tablib/core.py
+++ b/src/tablib/core.py
@@ -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)
diff --git a/tests/test_tablib.py b/tests/test_tablib.py
index 3acdd44..3d71da5 100755
--- a/tests/test_tablib.py
+++ b/tests/test_tablib.py
@@ -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__."""