Skip to content

Commit 8d57450

Browse files
authored
TST: remove __main__ from all test files (pandas-dev#15330)
1 parent 6d2293f commit 8d57450

File tree

112 files changed

+21
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+21
-703
lines changed

pandas/api/tests/test_api.py

-5
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,3 @@ def test_deprecation_access_obj(self):
227227
with tm.assert_produces_warning(FutureWarning,
228228
check_stacklevel=False):
229229
pd.datetools.monthEnd
230-
231-
if __name__ == '__main__':
232-
import nose
233-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
234-
exit=False)

pandas/computation/tests/test_compat.py

-5
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,3 @@ def testit():
6161
testit()
6262
else:
6363
testit()
64-
65-
66-
if __name__ == '__main__':
67-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
68-
exit=False)

pandas/computation/tests/test_eval.py

-5
Original file line numberDiff line numberDiff line change
@@ -1977,8 +1977,3 @@ def test_validate_bool_args(self):
19771977
for value in invalid_values:
19781978
with self.assertRaises(ValueError):
19791979
pd.eval("2+2", inplace=value)
1980-
1981-
1982-
if __name__ == '__main__':
1983-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
1984-
exit=False)

pandas/core/frame.py

-5
Original file line numberDiff line numberDiff line change
@@ -5762,8 +5762,3 @@ def boxplot(self, column=None, by=None, ax=None, fontsize=None, rot=0,
57625762

57635763
ops.add_flex_arithmetic_methods(DataFrame, **ops.frame_flex_funcs)
57645764
ops.add_special_arithmetic_methods(DataFrame, **ops.frame_special_funcs)
5765-
5766-
if __name__ == '__main__':
5767-
import nose
5768-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
5769-
exit=False)

pandas/formats/format.py

-14
Original file line numberDiff line numberDiff line change
@@ -2679,17 +2679,3 @@ def _binify(cols, line_width):
26792679

26802680
bins.append(len(cols))
26812681
return bins
2682-
2683-
2684-
if __name__ == '__main__':
2685-
arr = np.array([746.03, 0.00, 5620.00, 1592.36])
2686-
# arr = np.array([11111111.1, 1.55])
2687-
# arr = [314200.0034, 1.4125678]
2688-
arr = np.array(
2689-
[327763.3119, 345040.9076, 364460.9915, 398226.8688, 383800.5172,
2690-
433442.9262, 539415.0568, 568590.4108, 599502.4276, 620921.8593,
2691-
620898.5294, 552427.1093, 555221.2193, 519639.7059, 388175.7,
2692-
379199.5854, 614898.25, 504833.3333, 560600., 941214.2857, 1134250.,
2693-
1219550., 855736.85, 1042615.4286, 722621.3043, 698167.1818, 803750.])
2694-
fmt = FloatArrayFormatter(arr, digits=7)
2695-
print(fmt.get_result())

pandas/io/tests/json/test_normalize.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import nose
2-
31
from pandas import DataFrame
42
import numpy as np
53
import json
@@ -283,8 +281,3 @@ def test_json_normalize_errors(self):
283281
['general', 'trade_version']],
284282
errors='raise'
285283
)
286-
287-
288-
if __name__ == '__main__':
289-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb',
290-
'--pdb-failure', '-s'], exit=False)

pandas/io/tests/json/test_pandas.py

-5
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,3 @@ def roundtrip(s, encoding='latin-1'):
10441044

10451045
for s in examples:
10461046
roundtrip(s)
1047-
1048-
1049-
if __name__ == '__main__':
1050-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb',
1051-
'--pdb-failure', '-s'], exit=False)

pandas/io/tests/json/test_ujson.py

-5
Original file line numberDiff line numberDiff line change
@@ -1611,8 +1611,3 @@ def test_encodeSet(self):
16111611

16121612
def _clean_dict(d):
16131613
return dict((str(k), v) for k, v in compat.iteritems(d))
1614-
1615-
1616-
if __name__ == '__main__':
1617-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
1618-
exit=False)

pandas/io/tests/parser/test_network.py

-4
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,3 @@ def test_s3_fails(self):
182182
# It's irrelevant here that this isn't actually a table.
183183
with tm.assertRaises(IOError):
184184
read_csv('s3://cant_get_it/')
185-
186-
if __name__ == '__main__':
187-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
188-
exit=False)

pandas/io/tests/parser/test_parsers.py

-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22

33
import os
4-
import nose
54

65
import pandas.util.testing as tm
76

@@ -99,7 +98,3 @@ def read_table(self, *args, **kwds):
9998
kwds = kwds.copy()
10099
kwds['engine'] = self.engine
101100
return read_table(*args, **kwds)
102-
103-
if __name__ == '__main__':
104-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
105-
exit=False)

pandas/io/tests/parser/test_textreader.py

-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import os
1212
import sys
13-
import nose
1413

1514
from numpy import nan
1615
import numpy as np
@@ -402,7 +401,3 @@ def test_empty_csv_input(self):
402401
def assert_array_dicts_equal(left, right):
403402
for k, v in compat.iteritems(left):
404403
assert(np.array_equal(v, right[k]))
405-
406-
if __name__ == '__main__':
407-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
408-
exit=False)

pandas/io/tests/parser/test_unsupported.py

-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
test suite as new feature support is added to the parsers.
1010
"""
1111

12-
import nose
13-
1412
import pandas.io.parsers as parsers
1513
import pandas.util.testing as tm
1614

@@ -142,7 +140,3 @@ def test_deprecated_args(self):
142140
kwargs = {arg: non_default_val}
143141
read_csv(StringIO(data), engine=engine,
144142
**kwargs)
145-
146-
if __name__ == '__main__':
147-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
148-
exit=False)

pandas/io/tests/test_date_converters.py

-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from pandas.compat import StringIO
22
from datetime import date, datetime
33

4-
import nose
5-
64
import numpy as np
75

86
from pandas import DataFrame, MultiIndex
@@ -150,7 +148,3 @@ def test_parse_date_column_with_empty_string(self):
150148
[621, ' ']]
151149
expected = DataFrame(expected_data, columns=['case', 'opdate'])
152150
assert_frame_equal(result, expected)
153-
154-
if __name__ == '__main__':
155-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
156-
exit=False)

pandas/io/tests/test_excel.py

-5
Original file line numberDiff line numberDiff line change
@@ -2325,8 +2325,3 @@ def check_called(func):
23252325
check_called(lambda: panel.to_excel('something.test'))
23262326
check_called(lambda: df.to_excel('something.xlsx'))
23272327
check_called(lambda: df.to_excel('something.xls', engine='dummy'))
2328-
2329-
2330-
if __name__ == '__main__':
2331-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
2332-
exit=False)

pandas/io/tests/test_feather.py

-5
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,3 @@ def test_write_with_index(self):
116116
df.index = [0, 1, 2]
117117
df.columns = pd.MultiIndex.from_tuples([('a', 1), ('a', 2), ('b', 1)]),
118118
self.check_error_on_write(df, ValueError)
119-
120-
121-
if __name__ == '__main__':
122-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
123-
exit=False)

pandas/io/tests/test_gbq.py

-4
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,3 @@ def test_upload_data_as_service_account_with_key_contents(self):
12241224
project_id=_get_project_id(),
12251225
private_key=_get_private_key_contents())
12261226
self.assertEqual(result['NUM_ROWS'][0], test_size)
1227-
1228-
if __name__ == '__main__':
1229-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
1230-
exit=False)

pandas/io/tests/test_html.py

-4
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,3 @@ def test_same_ordering():
918918
dfs_lxml = read_html(filename, index_col=0, flavor=['lxml'])
919919
dfs_bs4 = read_html(filename, index_col=0, flavor=['bs4'])
920920
assert_framelist_equal(dfs_lxml, dfs_bs4)
921-
922-
if __name__ == '__main__':
923-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
924-
exit=False)

pandas/io/tests/test_pickle.py

-6
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,3 @@ def test_pickle_v0_15_2(self):
283283
# with open(pickle_path, 'wb') as f: pickle.dump(cat, f)
284284
#
285285
tm.assert_categorical_equal(cat, pd.read_pickle(pickle_path))
286-
287-
288-
if __name__ == '__main__':
289-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
290-
# '--with-coverage', '--cover-package=pandas.core'],
291-
exit=False)

pandas/io/tests/test_pytables.py

-6
Original file line numberDiff line numberDiff line change
@@ -5516,9 +5516,3 @@ def _test_sort(obj):
55165516
return obj.reindex(major=sorted(obj.major_axis))
55175517
else:
55185518
raise ValueError('type not supported here')
5519-
5520-
5521-
if __name__ == '__main__':
5522-
import nose
5523-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
5524-
exit=False)

pandas/io/tests/test_s3.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import nose
21
from pandas.util import testing as tm
32

43
from pandas.io.common import _is_s3_url
54

65

76
class TestS3URL(tm.TestCase):
7+
88
def test_is_s3_url(self):
99
self.assertTrue(_is_s3_url("s3://pandas/somethingelse.com"))
1010
self.assertFalse(_is_s3_url("s4://pandas/somethingelse.com"))
11-
12-
if __name__ == '__main__':
13-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
14-
exit=False)

pandas/io/tests/test_sql.py

-5
Original file line numberDiff line numberDiff line change
@@ -2658,8 +2658,3 @@ def clean_up(test_table_to_drop):
26582658
self.assertEqual(tquery(sql_select, con=self.conn),
26592659
[(1, 'A'), (2, 'B'), (3, 'C'), (4, 'D'), (5, 'E')])
26602660
clean_up(table_name)
2661-
2662-
2663-
if __name__ == '__main__':
2664-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
2665-
exit=False)

pandas/io/tests/test_stata.py

-5
Original file line numberDiff line numberDiff line change
@@ -1276,8 +1276,3 @@ def test_out_of_range_float(self):
12761276
original.to_stata(path)
12771277
tm.assertTrue('ColumnTooBig' in cm.exception)
12781278
tm.assertTrue('infinity' in cm.exception)
1279-
1280-
1281-
if __name__ == '__main__':
1282-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
1283-
exit=False)

pandas/sparse/tests/test_array.py

-6
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,3 @@ def test_ufunc_args(self):
810810
sparse = SparseArray([1, -1, 0, -2], fill_value=0)
811811
result = SparseArray([2, 0, 1, -1], fill_value=1)
812812
tm.assert_sp_array_equal(np.add(sparse, 1), result)
813-
814-
815-
if __name__ == '__main__':
816-
import nose
817-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
818-
exit=False)

pandas/sparse/tests/test_combine_concat.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# pylint: disable-msg=E1101,W0612
22

3-
import nose # noqa
43
import numpy as np
54
import pandas as pd
65
import pandas.util.testing as tm
@@ -356,9 +355,3 @@ def test_concat_sparse_dense(self):
356355
exp = pd.concat([self.dense1, self.dense3], axis=1)
357356
self.assertIsInstance(res, pd.SparseDataFrame)
358357
tm.assert_frame_equal(res, exp)
359-
360-
361-
if __name__ == '__main__':
362-
import nose # noqa
363-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
364-
exit=False)

pandas/sparse/tests/test_frame.py

-5
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,3 @@ def test_numpy_func_call(self):
11931193
'std', 'min', 'max']
11941194
for func in funcs:
11951195
getattr(np, func)(self.frame)
1196-
1197-
if __name__ == '__main__':
1198-
import nose
1199-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
1200-
exit=False)

pandas/sparse/tests/test_libsparse.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pandas import Series
22

3-
import nose # noqa
3+
import nose
44
import numpy as np
55
import operator
66
import pandas.util.testing as tm
@@ -196,7 +196,7 @@ def _check_correct(a, b, expected):
196196
assert (result.equals(expected))
197197

198198
def _check_length_exc(a, longer):
199-
nose.tools.assert_raises(Exception, a.intersect, longer)
199+
self.assertRaises(Exception, a.intersect, longer)
200200

201201
def _check_case(xloc, xlen, yloc, ylen, eloc, elen):
202202
xindex = BlockIndex(TEST_LENGTH, xloc, xlen)
@@ -585,9 +585,3 @@ def f(self):
585585
g = make_optestf(op)
586586
setattr(TestSparseOperators, g.__name__, g)
587587
del g
588-
589-
590-
if __name__ == '__main__':
591-
import nose # noqa
592-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
593-
exit=False)

pandas/sparse/tests/test_list.py

-6
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,3 @@ def test_getitem(self):
112112
for i in range(len(arr)):
113113
tm.assert_almost_equal(splist[i], arr[i])
114114
tm.assert_almost_equal(splist[-i], arr[-i])
115-
116-
117-
if __name__ == '__main__':
118-
import nose
119-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
120-
exit=False)

pandas/sparse/tests/test_series.py

-6
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,3 @@ def test_numpy_func_call(self):
13661366
for func in funcs:
13671367
for series in ('bseries', 'zbseries'):
13681368
getattr(np, func)(getattr(self, series))
1369-
1370-
1371-
if __name__ == '__main__':
1372-
import nose
1373-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
1374-
exit=False)

pandas/stats/tests/test_fama_macbeth.py

-5
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,3 @@ def _check_stuff_works(self, result):
6666

6767
# does it work?
6868
result.summary
69-
70-
if __name__ == '__main__':
71-
import nose
72-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
73-
exit=False)

pandas/stats/tests/test_math.py

-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,3 @@ def test_inv_illformed(self):
5757
rs = pmath.inv(singular)
5858
expected = np.array([[0.1, 0.2], [0.1, 0.2]])
5959
self.assertTrue(np.allclose(rs, expected))
60-
61-
if __name__ == '__main__':
62-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
63-
exit=False)

pandas/stats/tests/test_ols.py

-6
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,3 @@ def testFilterWithDictRHS(self):
974974

975975
def tsAssertEqual(self, ts1, ts2, **kwargs):
976976
self.assert_series_equal(ts1, ts2, **kwargs)
977-
978-
979-
if __name__ == '__main__':
980-
import nose
981-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
982-
exit=False)

pandas/stats/tests/test_var.py

-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from pandas.compat import range
88
import nose
9-
import unittest
109

1110
raise nose.SkipTest('skipping this for now')
1211

@@ -93,7 +92,3 @@ def __init__(self):
9392
self.res1 = VAR2(endog=data).fit(maxlag=2)
9493
from results import results_var
9594
self.res2 = results_var.MacrodataResults()
96-
97-
98-
if __name__ == '__main__':
99-
unittest.main()

pandas/tests/formats/test_format.py

-5
Original file line numberDiff line numberDiff line change
@@ -4999,8 +4999,3 @@ def test_format_percentiles():
49994999
tm.assertRaises(ValueError, fmt.format_percentiles, [-0.001, 0.1, 0.5])
50005000
tm.assertRaises(ValueError, fmt.format_percentiles, [2, 0.1, 0.5])
50015001
tm.assertRaises(ValueError, fmt.format_percentiles, [0.1, 0.5, 'a'])
5002-
5003-
5004-
if __name__ == '__main__':
5005-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
5006-
exit=False)

pandas/tests/formats/test_printing.py

-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
import nose
32
from pandas import compat
43
import pandas.formats.printing as printing
54
import pandas.formats.format as fmt
@@ -135,8 +134,3 @@ def test_ambiguous_width(self):
135134
# result = printing.console_encode(u"\u05d0")
136135
# expected = u"\u05d0".encode('utf-8')
137136
# assert (result == expected)
138-
139-
140-
if __name__ == '__main__':
141-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
142-
exit=False)

0 commit comments

Comments
 (0)