Skip to content

TST: Use pytest #13856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
TST: Refactor to use setup_class
Pytest won't use setUp unless you inherit from TestCase.
These classes don't because they use nose-style generator
tests. We change to setup_class becuase that is called by
the pytest runner.
  • Loading branch information
TomAugspurger committed Feb 10, 2017
commit c8dc92731545737722c680e71bb21258ac621072
21 changes: 11 additions & 10 deletions pandas/io/tests/test_packers.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,18 +793,19 @@ class TestMsgpack():
http://stackoverflow.com/questions/6689537/nose-test-generators-inside-class
"""

def setUp(self):
@classmethod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pytest will run setup but not setUp before each test in a class. Guessing this change in structure was intentional.

def setup_class(cls):
from pandas.io.tests.generate_legacy_storage_files import (
create_msgpack_data, create_data)
self.data = create_msgpack_data()
self.all_data = create_data()
self.path = u('__%s__.msgpack' % tm.rands(10))
self.minimum_structure = {'series': ['float', 'int', 'mixed',
'ts', 'mi', 'dup'],
'frame': ['float', 'int', 'mixed', 'mi'],
'panel': ['float'],
'index': ['int', 'date', 'period'],
'mi': ['reg2']}
cls.data = create_msgpack_data()
cls.all_data = create_data()
cls.path = u('__%s__.msgpack' % tm.rands(10))
cls.minimum_structure = {'series': ['float', 'int', 'mixed',
'ts', 'mi', 'dup'],
'frame': ['float', 'int', 'mixed', 'mi'],
'panel': ['float'],
'index': ['int', 'date', 'period'],
'mi': ['reg2']}

def check_min_structure(self, data):
for typ, v in self.minimum_structure.items():
Expand Down
7 changes: 4 additions & 3 deletions pandas/io/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ class TestPickle():
nose-test-generators-inside-class
"""

def setUp(self):
@classmethod
def setup_class(cls):
from pandas.io.tests.generate_legacy_storage_files import (
create_pickle_data)
self.data = create_pickle_data()
self.path = u('__%s__.pickle' % tm.rands(10))
cls.data = create_pickle_data()
cls.path = u('__%s__.pickle' % tm.rands(10))

def compare_element(self, result, expected, typ, version=None):
if isinstance(expected, Index):
Expand Down