Skip to content

Commit cb9997b

Browse files
gfyoungstangirala
authored andcommitted
TST: Remove __init__ statements in testing (pandas-dev#16238)
Closes pandas-devgh-16235.
1 parent 1f4498e commit cb9997b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

pandas/tests/indexes/test_multi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def test_copy_names(self):
486486

487487
def test_names(self):
488488

489-
# names are assigned in __init__
489+
# names are assigned in setup
490490
names = self.index_names
491491
level_names = [level.name for level in self.index.levels]
492492
assert names == level_names

pandas/tests/test_config.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@
88

99
class TestConfig(object):
1010

11-
def __init__(self, *args):
12-
super(TestConfig, self).__init__(*args)
13-
11+
@classmethod
12+
def setup_class(cls):
1413
from copy import deepcopy
15-
self.cf = pd.core.config
16-
self.gc = deepcopy(getattr(self.cf, '_global_config'))
17-
self.do = deepcopy(getattr(self.cf, '_deprecated_options'))
18-
self.ro = deepcopy(getattr(self.cf, '_registered_options'))
14+
15+
cls.cf = pd.core.config
16+
cls.gc = deepcopy(getattr(cls.cf, '_global_config'))
17+
cls.do = deepcopy(getattr(cls.cf, '_deprecated_options'))
18+
cls.ro = deepcopy(getattr(cls.cf, '_registered_options'))
1919

2020
def setup_method(self, method):
2121
setattr(self.cf, '_global_config', {})
22-
setattr(
23-
self.cf, 'options', self.cf.DictWrapper(self.cf._global_config))
22+
setattr(self.cf, 'options', self.cf.DictWrapper(
23+
self.cf._global_config))
2424
setattr(self.cf, '_deprecated_options', {})
2525
setattr(self.cf, '_registered_options', {})
2626

27+
# Our test fixture in conftest.py sets "chained_assignment"
28+
# to "raise" only after all test methods have been setup.
29+
# However, after this setup, there is no longer any
30+
# "chained_assignment" option, so re-register it.
31+
self.cf.register_option('chained_assignment', 'raise')
32+
2733
def teardown_method(self, method):
2834
setattr(self.cf, '_global_config', self.gc)
2935
setattr(self.cf, '_deprecated_options', self.do)

0 commit comments

Comments
 (0)