Skip to content

Commit

Permalink
TST: Remove __init__ statements in testing (#16238)
Browse files Browse the repository at this point in the history
Closes gh-16235.
  • Loading branch information
gfyoung authored and jreback committed May 4, 2017
1 parent 8ebd65b commit a54efdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def test_copy_names(self):

def test_names(self):

# names are assigned in __init__
# names are assigned in setup
names = self.index_names
level_names = [level.name for level in self.index.levels]
assert names == level_names
Expand Down
24 changes: 15 additions & 9 deletions pandas/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@

class TestConfig(object):

def __init__(self, *args):
super(TestConfig, self).__init__(*args)

@classmethod
def setup_class(cls):
from copy import deepcopy
self.cf = pd.core.config
self.gc = deepcopy(getattr(self.cf, '_global_config'))
self.do = deepcopy(getattr(self.cf, '_deprecated_options'))
self.ro = deepcopy(getattr(self.cf, '_registered_options'))

cls.cf = pd.core.config
cls.gc = deepcopy(getattr(cls.cf, '_global_config'))
cls.do = deepcopy(getattr(cls.cf, '_deprecated_options'))
cls.ro = deepcopy(getattr(cls.cf, '_registered_options'))

def setup_method(self, method):
setattr(self.cf, '_global_config', {})
setattr(
self.cf, 'options', self.cf.DictWrapper(self.cf._global_config))
setattr(self.cf, 'options', self.cf.DictWrapper(
self.cf._global_config))
setattr(self.cf, '_deprecated_options', {})
setattr(self.cf, '_registered_options', {})

# Our test fixture in conftest.py sets "chained_assignment"
# to "raise" only after all test methods have been setup.
# However, after this setup, there is no longer any
# "chained_assignment" option, so re-register it.
self.cf.register_option('chained_assignment', 'raise')

def teardown_method(self, method):
setattr(self.cf, '_global_config', self.gc)
setattr(self.cf, '_deprecated_options', self.do)
Expand Down

0 comments on commit a54efdd

Please sign in to comment.