Repository: jazzband/tablib (python)

Issue:
Row.lpush/rpush behavior is reversed
As discovered while testing #450, `Row.lpush` is appending, while `Row.rpush` is prepending, which is counter-intuitive (and doesn't match the `Dataset.lpush/rpush`behavior).

Pull request description:
Fixes #453 - Reversing behavior of Row.lpush/Row.rpush
Co-authored-by: chim <chenpan@xiaomai5.com>

Patch:
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)


Test patch:
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__."""