Skip to content

Commit e640d0f

Browse files
committed
TST: changed refs to use testing/TestCase where setUpClass/tearDownClass are defined
1 parent 713a105 commit e640d0f

File tree

9 files changed

+75
-76
lines changed

9 files changed

+75
-76
lines changed

pandas/computation/tests/test_eval.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
import unittest
43
import functools
54
from itertools import product
65

@@ -104,10 +103,11 @@ def _is_py3_complex_incompat(result, expected):
104103
_good_arith_ops = com.difference(_arith_ops_syms, _special_case_arith_ops_syms)
105104

106105

107-
class TestEvalNumexprPandas(unittest.TestCase):
106+
class TestEvalNumexprPandas(tm.TestCase):
108107

109108
@classmethod
110109
def setUpClass(cls):
110+
super(TestEvalNumexprPandas, cls).setUpClass()
111111
skip_if_no_ne()
112112
import numexpr as ne
113113
cls.ne = ne
@@ -116,6 +116,7 @@ def setUpClass(cls):
116116

117117
@classmethod
118118
def tearDownClass(cls):
119+
super(TestEvalNumexprPandas, cls).tearDownClass()
119120
del cls.engine, cls.parser
120121
if hasattr(cls, 'ne'):
121122
del cls.ne
@@ -707,6 +708,7 @@ class TestEvalNumexprPython(TestEvalNumexprPandas):
707708

708709
@classmethod
709710
def setUpClass(cls):
711+
super(TestEvalNumexprPython, cls).setUpClass()
710712
skip_if_no_ne()
711713
import numexpr as ne
712714
cls.ne = ne
@@ -733,6 +735,7 @@ class TestEvalPythonPython(TestEvalNumexprPython):
733735

734736
@classmethod
735737
def setUpClass(cls):
738+
super(TestEvalPythonPython, cls).setUpClass()
736739
cls.engine = 'python'
737740
cls.parser = 'python'
738741

@@ -761,6 +764,7 @@ class TestEvalPythonPandas(TestEvalPythonPython):
761764

762765
@classmethod
763766
def setUpClass(cls):
767+
super(TestEvalPythonPandas, cls).setUpClass()
764768
cls.engine = 'python'
765769
cls.parser = 'pandas'
766770

@@ -1024,17 +1028,19 @@ def test_performance_warning_for_poor_alignment(self):
10241028
#------------------------------------
10251029
# slightly more complex ops
10261030

1027-
class TestOperationsNumExprPandas(unittest.TestCase):
1031+
class TestOperationsNumExprPandas(tm.TestCase):
10281032

10291033
@classmethod
10301034
def setUpClass(cls):
1035+
super(TestOperationsNumExprPandas, cls).setUpClass()
10311036
skip_if_no_ne()
10321037
cls.engine = 'numexpr'
10331038
cls.parser = 'pandas'
10341039
cls.arith_ops = expr._arith_ops_syms + expr._cmp_ops_syms
10351040

10361041
@classmethod
10371042
def tearDownClass(cls):
1043+
super(TestOperationsNumExprPandas, cls).tearDownClass()
10381044
del cls.engine, cls.parser
10391045

10401046
def eval(self, *args, **kwargs):
@@ -1337,6 +1343,7 @@ class TestOperationsNumExprPython(TestOperationsNumExprPandas):
13371343

13381344
@classmethod
13391345
def setUpClass(cls):
1346+
super(TestOperationsNumExprPython, cls).setUpClass()
13401347
if not _USE_NUMEXPR:
13411348
raise nose.SkipTest("numexpr engine not installed")
13421349
cls.engine = 'numexpr'
@@ -1404,6 +1411,7 @@ class TestOperationsPythonPython(TestOperationsNumExprPython):
14041411

14051412
@classmethod
14061413
def setUpClass(cls):
1414+
super(TestOperationsPythonPython, cls).setUpClass()
14071415
cls.engine = cls.parser = 'python'
14081416
cls.arith_ops = expr._arith_ops_syms + expr._cmp_ops_syms
14091417
cls.arith_ops = filter(lambda x: x not in ('in', 'not in'),
@@ -1414,6 +1422,7 @@ class TestOperationsPythonPandas(TestOperationsNumExprPandas):
14141422

14151423
@classmethod
14161424
def setUpClass(cls):
1425+
super(TestOperationsPythonPandas, cls).setUpClass()
14171426
cls.engine = 'python'
14181427
cls.parser = 'pandas'
14191428
cls.arith_ops = expr._arith_ops_syms + expr._cmp_ops_syms

pandas/io/tests/test_clipboard.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import unittest
2-
31
import numpy as np
42
from numpy.random import randint
53

@@ -18,9 +16,10 @@
1816
raise nose.SkipTest("no clipboard found")
1917

2018

21-
class TestClipboard(unittest.TestCase):
19+
class TestClipboard(tm.TestCase):
2220
@classmethod
2321
def setUpClass(cls):
22+
super(TestClipboard, cls).setupClass()
2423
cls.data = {}
2524
cls.data['string'] = mkdf(5, 3, c_idx_type='s', r_idx_type='i',
2625
c_idx_names=[None], r_idx_names=[None])
@@ -43,6 +42,7 @@ def setUpClass(cls):
4342

4443
@classmethod
4544
def tearDownClass(cls):
45+
super(TestClipboard, cls).tearDownClass()
4646
del cls.data_types, cls.data
4747

4848
def check_round_trip_frame(self, data_type, excel=None, sep=None):

pandas/io/tests/test_data.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import print_function
22
from pandas import compat
3-
import unittest
43
import warnings
54
import nose
65
from nose.tools import assert_equal
@@ -35,15 +34,17 @@ def assert_n_failed_equals_n_null_columns(wngs, obj, cls=SymbolWarning):
3534
assert msgs.str.contains('|'.join(failed_symbols)).all()
3635

3736

38-
class TestGoogle(unittest.TestCase):
37+
class TestGoogle(tm.TestCase):
3938
@classmethod
4039
def setUpClass(cls):
40+
super(TestGoogle, cls).setupClass()
4141
cls.locales = tm.get_locales(prefix='en_US')
4242
if not cls.locales:
4343
raise nose.SkipTest("US English locale not available for testing")
4444

4545
@classmethod
4646
def tearDownClass(cls):
47+
super(TestGoogle, cls).tearDownClass()
4748
del cls.locales
4849

4950
@network
@@ -105,9 +106,10 @@ def test_get_multi2(self):
105106
assert_n_failed_equals_n_null_columns(w, result)
106107

107108

108-
class TestYahoo(unittest.TestCase):
109+
class TestYahoo(tm.TestCase):
109110
@classmethod
110111
def setUpClass(cls):
112+
super(TestYahoo, cls).setupClass()
111113
_skip_if_no_lxml()
112114

113115
@network
@@ -224,9 +226,10 @@ def test_get_date_ret_index(self):
224226
assert np.issubdtype(pan.values.dtype, np.floating)
225227

226228

227-
class TestYahooOptions(unittest.TestCase):
229+
class TestYahooOptions(tm.TestCase):
228230
@classmethod
229231
def setUpClass(cls):
232+
super(TestYahooOptions, cls).setupClass()
230233
_skip_if_no_lxml()
231234

232235
# aapl has monthlies
@@ -241,6 +244,7 @@ def setUpClass(cls):
241244

242245
@classmethod
243246
def tearDownClass(cls):
247+
super(TestYahooOptions, cls).tearDownClass()
244248
del cls.aapl, cls.expiry
245249

246250
@network
@@ -283,9 +287,10 @@ def test_get_put_data(self):
283287
assert len(puts)>1
284288

285289

286-
class TestOptionsWarnings(unittest.TestCase):
290+
class TestOptionsWarnings(tm.TestCase):
287291
@classmethod
288292
def setUpClass(cls):
293+
super(TestOptionsWarnings, cls).setupClass()
289294
_skip_if_no_lxml()
290295

291296
with assert_produces_warning(FutureWarning):
@@ -300,6 +305,7 @@ def setUpClass(cls):
300305

301306
@classmethod
302307
def tearDownClass(cls):
308+
super(TestOptionsWarnings, cls).tearDownClass()
303309
del cls.aapl, cls.year, cls.month
304310

305311
@network
@@ -342,7 +348,7 @@ def test_get_put_data_warning(self):
342348
warnings.warn("IndexError thrown no tables found")
343349

344350

345-
class TestDataReader(unittest.TestCase):
351+
class TestDataReader(tm.TestCase):
346352
def test_is_s3_url(self):
347353
from pandas.io.common import _is_s3_url
348354
self.assert_(_is_s3_url("s3://pandas/somethingelse.com"))
@@ -372,7 +378,7 @@ def test_read_famafrench(self):
372378
assert isinstance(ff, dict)
373379

374380

375-
class TestFred(unittest.TestCase):
381+
class TestFred(tm.TestCase):
376382
@network
377383
def test_fred(self):
378384
"""

pandas/io/tests/test_gbq.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import shutil
55
import subprocess
6-
import unittest
76

87
import numpy as np
98

@@ -41,18 +40,18 @@ def GetTableSchema(self,table_dict):
4140
class FakeApiClient:
4241
def __init__(self):
4342
self._fakejobs = FakeJobs()
44-
43+
4544

4645
def jobs(self):
4746
return self._fakejobs
4847

4948
class FakeJobs:
50-
def __init__(self):
49+
def __init__(self):
5150
self._fakequeryresults = FakeResults()
5251

5352
def getQueryResults(self, job_id=None, project_id=None,
5453
max_results=None, timeout_ms=None, **kwargs):
55-
return self._fakequeryresults
54+
return self._fakequeryresults
5655

5756
class FakeResults:
5857
def execute(self):
@@ -74,7 +73,7 @@ def execute(self):
7473

7574
####################################################################################
7675

77-
class test_gbq(unittest.TestCase):
76+
class TestGbq(tm.TestCase):
7877
def setUp(self):
7978
with open(self.fake_job_path, 'r') as fin:
8079
self.fake_job = ast.literal_eval(fin.read())
@@ -102,7 +101,7 @@ def setUp(self):
102101
('othello', 1603, 'brawl', 2),
103102
('othello', 1603, "'", 17),
104103
('othello', 1603, 'troubled', 1)
105-
],
104+
],
106105
dtype=[('corpus', 'S16'),
107106
('corpus_date', '<i8'),
108107
('word', 'S16'),
@@ -137,17 +136,18 @@ def setUp(self):
137136
'TRUE_BOOLEAN',
138137
'FALSE_BOOLEAN',
139138
'NULL_BOOLEAN']]
140-
139+
141140
@classmethod
142141
def setUpClass(self):
143142
# Integration tests require a valid bigquery token
144143
# be present in the user's home directory. This
145144
# can be generated with 'bq init' in the command line
145+
super(TestGbq, cls).setupClass()
146146
self.dirpath = tm.get_data_path()
147147
home = os.path.expanduser("~")
148148
self.bq_token = os.path.join(home, '.bigquery.v2.token')
149149
self.fake_job_path = os.path.join(self.dirpath, 'gbq_fake_job.txt')
150-
150+
151151
# If we're using a valid token, make a test dataset
152152
# Note, dataset functionality is beyond the scope
153153
# of the module under test, so we rely on the command
@@ -167,7 +167,7 @@ def test_valid_authentication(self):
167167
# If the user has a token file, they should recieve a client from gbq._authenticate
168168
if not os.path.exists(self.bq_token):
169169
raise nose.SkipTest('Skipped because authentication information is not available.')
170-
170+
171171
self.assertTrue(gbq._authenticate is not None, 'Authentication To GBQ Failed')
172172

173173
@with_connectivity_check
@@ -205,14 +205,14 @@ def test_data_small(self):
205205
'An element in the result DataFrame didn\'t match the sample set')
206206

207207
def test_index_column(self):
208-
# A user should be able to specify an index column for return
208+
# A user should be able to specify an index column for return
209209
result_frame = gbq._parse_data(FakeClient(), self.fake_job, index_col='word')
210210
correct_frame = DataFrame(self.correct_data_small)
211211
correct_frame.set_index('word', inplace=True)
212212
self.assertTrue(result_frame.index.name == correct_frame.index.name)
213213

214214
def test_column_order(self):
215-
# A User should be able to specify the order in which columns are returned in the dataframe
215+
# A User should be able to specify the order in which columns are returned in the dataframe
216216
col_order = ['corpus_date', 'word_count', 'corpus', 'word']
217217
result_frame = gbq._parse_data(FakeClient(), self.fake_job, col_order=col_order)
218218
tm.assert_index_equal(result_frame.columns, DataFrame(self.correct_data_small)[col_order].columns)
@@ -279,8 +279,8 @@ def test_download_all_data_types(self):
279279
@with_connectivity_check
280280
def test_table_exists(self):
281281
# Given a table name in the format {dataset}.{tablename}, if a table exists,
282-
# the GetTableReference should accurately indicate this.
283-
# This could possibly change in future implementations of bq,
282+
# the GetTableReference should accurately indicate this.
283+
# This could possibly change in future implementations of bq,
284284
# but it is the simplest way to provide users with appropriate
285285
# error messages regarding schemas.
286286
if not os.path.exists(self.bq_token):
@@ -309,7 +309,7 @@ def test_upload_new_table_schema_error(self):
309309
df = DataFrame(self.correct_data_small)
310310
with self.assertRaises(gbq.SchemaMissing):
311311
gbq.to_gbq(df, 'pandas_testing_dataset.test_database', schema=None, col_order=None, if_exists='fail')
312-
312+
313313
@with_connectivity_check
314314
def test_upload_replace_schema_error(self):
315315
# Attempting to replace an existing table without specifying a schema should fail
@@ -319,7 +319,7 @@ def test_upload_replace_schema_error(self):
319319
df = DataFrame(self.correct_data_small)
320320
with self.assertRaises(gbq.SchemaMissing):
321321
gbq.to_gbq(df, 'pandas_testing_dataset.test_database', schema=None, col_order=None, if_exists='replace')
322-
322+
323323
@with_connectivity_check
324324
def test_upload_public_data_error(self):
325325
# Attempting to upload to a public, read-only, dataset should fail
@@ -432,7 +432,7 @@ def test_upload_replace(self):
432432
'contributor_ip','contributor_id','contributor_username','timestamp',
433433
'is_minor','is_bot','reversion_id','comment','num_characters'])
434434
gbq.to_gbq(df1, 'pandas_testing_dataset.test_data5', schema=schema, col_order=None, if_exists='fail')
435-
435+
436436
array2 = [['TESTING_GBQ', 999999999, 'hi', 0, True, 9999999999, '00.000.00.000', 1, 'hola',
437437
99999999, False, False, 1, 'Jedi', 11210]]
438438

@@ -441,7 +441,7 @@ def test_upload_replace(self):
441441
'contributor_ip','contributor_id','contributor_username','timestamp',
442442
'is_minor','is_bot','reversion_id','comment','num_characters'])
443443
gbq.to_gbq(df2, 'pandas_testing_dataset.test_data5', schema=schema, col_order=None, if_exists='replace')
444-
444+
445445
# Read the table and confirm the new data is all that is there
446446
a = gbq.read_gbq("SELECT * FROM pandas_testing_dataset.test_data5")
447447
self.assertTrue((a == df2).all().all())

pandas/io/tests/test_html.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import re
55
import warnings
6-
import unittest
76

87
try:
98
from importlib import import_module
@@ -85,9 +84,10 @@ def test_bs4_version_fails():
8584
flavor='bs4')
8685

8786

88-
class TestReadHtml(unittest.TestCase):
87+
class TestReadHtml(tm.TestCase):
8988
@classmethod
9089
def setUpClass(cls):
90+
super(TestReadHtml, cls).setupClass()
9191
_skip_if_none_of(('bs4', 'html5lib'))
9292

9393
def read_html(self, *args, **kwargs):
@@ -582,9 +582,10 @@ def test_parse_dates_combine(self):
582582
tm.assert_frame_equal(newdf, res[0])
583583

584584

585-
class TestReadHtmlLxml(unittest.TestCase):
585+
class TestReadHtmlLxml(tm.TestCase):
586586
@classmethod
587587
def setUpClass(cls):
588+
super(TestReadHtmlLxml, cls).setupClass()
588589
_skip_if_no('lxml')
589590

590591
def read_html(self, *args, **kwargs):

0 commit comments

Comments
 (0)