Skip to content

Commit

Permalink
Fixturize tests/frame/test_mutate_columns.py (#25642)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari authored and jreback committed Mar 10, 2019
1 parent f2b578c commit 8117460
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions pandas/tests/frame/test_mutate_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
from pandas.compat import PY36, lrange, range

from pandas import DataFrame, Index, MultiIndex, Series
from pandas.tests.frame.common import TestData
import pandas.util.testing as tm
from pandas.util.testing import assert_frame_equal

# Column add, remove, delete.


class TestDataFrameMutateColumns(TestData):
class TestDataFrameMutateColumns():

def test_assign(self):
df = DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
Expand Down Expand Up @@ -193,9 +192,9 @@ def test_insert(self):
exp = DataFrame(data={'X': ['x', 'y', 'z']}, index=['A', 'B', 'C'])
assert_frame_equal(df, exp)

def test_delitem(self):
del self.frame['A']
assert 'A' not in self.frame
def test_delitem(self, float_frame):
del float_frame['A']
assert 'A' not in float_frame

def test_delitem_multiindex(self):
midx = MultiIndex.from_product([['A', 'B'], [1, 2]])
Expand Down Expand Up @@ -223,16 +222,16 @@ def test_delitem_multiindex(self):
with pytest.raises(KeyError):
del df['A']

def test_pop(self):
self.frame.columns.name = 'baz'
def test_pop(self, float_frame):
float_frame.columns.name = 'baz'

self.frame.pop('A')
assert 'A' not in self.frame
float_frame.pop('A')
assert 'A' not in float_frame

self.frame['foo'] = 'bar'
self.frame.pop('foo')
assert 'foo' not in self.frame
assert self.frame.columns.name == 'baz'
float_frame['foo'] = 'bar'
float_frame.pop('foo')
assert 'foo' not in float_frame
assert float_frame.columns.name == 'baz'

# gh-10912: inplace ops cause caching issue
a = DataFrame([[1, 2, 3], [4, 5, 6]], columns=[
Expand Down

0 comments on commit 8117460

Please sign in to comment.