From b11bd874b7d4e9c899e425e2a102bf3ad03fcbb3 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Tue, 2 May 2017 12:21:55 -0400 Subject: [PATCH] MAINT: Remove unittest.TestCase from testing --- pandas/tests/frame/test_validate.py | 4 ++-- pandas/tests/io/json/test_ujson.py | 8 +++----- pandas/tests/io/test_sql.py | 21 ++++++++++----------- pandas/tests/sparse/test_list.py | 3 +-- pandas/tests/test_config.py | 5 +++-- pandas/tests/test_testing.py | 7 +++---- pandas/tests/test_window.py | 4 ++-- 7 files changed, 24 insertions(+), 28 deletions(-) diff --git a/pandas/tests/frame/test_validate.py b/pandas/tests/frame/test_validate.py index 4c4abb7e58e757..343853b3fcfa0d 100644 --- a/pandas/tests/frame/test_validate.py +++ b/pandas/tests/frame/test_validate.py @@ -1,10 +1,10 @@ -from unittest import TestCase from pandas.core.frame import DataFrame +import pandas.util.testing as tm import pytest -class TestDataFrameValidate(TestCase): +class TestDataFrameValidate(tm.TestCase): """Tests for error handling related to data types of method arguments.""" df = DataFrame({'a': [1, 2], 'b': [3, 4]}) diff --git a/pandas/tests/io/json/test_ujson.py b/pandas/tests/io/json/test_ujson.py index b749cd150d445e..a23ae225c19b06 100644 --- a/pandas/tests/io/json/test_ujson.py +++ b/pandas/tests/io/json/test_ujson.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from unittest import TestCase - try: import json except ImportError: @@ -27,7 +25,7 @@ else partial(json.dumps, encoding="utf-8")) -class UltraJSONTests(TestCase): +class UltraJSONTests(tm.TestCase): @pytest.mark.skipif(compat.is_platform_32bit(), reason="not compliant on 32-bit, xref #15865") @@ -948,7 +946,7 @@ def my_obj_handler(obj): ujson.decode(ujson.encode(l, default_handler=str))) -class NumpyJSONTests(TestCase): +class NumpyJSONTests(tm.TestCase): def testBool(self): b = np.bool(True) @@ -1224,7 +1222,7 @@ def testArrayNumpyLabelled(self): assert (np.array(['a', 'b']) == output[2]).all() -class PandasJSONTests(TestCase): +class PandasJSONTests(tm.TestCase): def testDataFrame(self): df = DataFrame([[1, 2, 3], [4, 5, 6]], index=[ diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index 00296a45a19927..21de0cd371a371 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -20,7 +20,6 @@ from __future__ import print_function from warnings import catch_warnings import pytest -import unittest import sqlite3 import csv import os @@ -819,7 +818,7 @@ def test_unicode_column_name(self): @pytest.mark.single -class TestSQLApi(SQLAlchemyMixIn, _TestSQLApi, unittest.TestCase): +class TestSQLApi(SQLAlchemyMixIn, _TestSQLApi, tm.TestCase): """ Test the public API as it would be used directly @@ -999,12 +998,12 @@ def teardown_method(self, method): @pytest.mark.single -class TestSQLApiConn(_EngineToConnMixin, TestSQLApi, unittest.TestCase): +class TestSQLApiConn(_EngineToConnMixin, TestSQLApi, tm.TestCase): pass @pytest.mark.single -class TestSQLiteFallbackApi(SQLiteMixIn, _TestSQLApi, unittest.TestCase): +class TestSQLiteFallbackApi(SQLiteMixIn, _TestSQLApi, tm.TestCase): """ Test the public sqlite connection fallback API @@ -1822,37 +1821,37 @@ def test_schema_support(self): @pytest.mark.single -class TestMySQLAlchemy(_TestMySQLAlchemy, _TestSQLAlchemy, unittest.TestCase): +class TestMySQLAlchemy(_TestMySQLAlchemy, _TestSQLAlchemy, tm.TestCase): pass @pytest.mark.single class TestMySQLAlchemyConn(_TestMySQLAlchemy, _TestSQLAlchemyConn, - unittest.TestCase): + tm.TestCase): pass @pytest.mark.single class TestPostgreSQLAlchemy(_TestPostgreSQLAlchemy, _TestSQLAlchemy, - unittest.TestCase): + tm.TestCase): pass @pytest.mark.single class TestPostgreSQLAlchemyConn(_TestPostgreSQLAlchemy, _TestSQLAlchemyConn, - unittest.TestCase): + tm.TestCase): pass @pytest.mark.single class TestSQLiteAlchemy(_TestSQLiteAlchemy, _TestSQLAlchemy, - unittest.TestCase): + tm.TestCase): pass @pytest.mark.single class TestSQLiteAlchemyConn(_TestSQLiteAlchemy, _TestSQLAlchemyConn, - unittest.TestCase): + tm.TestCase): pass @@ -1860,7 +1859,7 @@ class TestSQLiteAlchemyConn(_TestSQLiteAlchemy, _TestSQLAlchemyConn, # -- Test Sqlite / MySQL fallback @pytest.mark.single -class TestSQLiteFallback(SQLiteMixIn, PandasSQLTest, unittest.TestCase): +class TestSQLiteFallback(SQLiteMixIn, PandasSQLTest, tm.TestCase): """ Test the fallback mode against an in-memory sqlite database. diff --git a/pandas/tests/sparse/test_list.py b/pandas/tests/sparse/test_list.py index 6aeb34a5094e68..3eab34661ae2b4 100644 --- a/pandas/tests/sparse/test_list.py +++ b/pandas/tests/sparse/test_list.py @@ -1,5 +1,4 @@ from pandas.compat import range -import unittest from numpy import nan import numpy as np @@ -8,7 +7,7 @@ import pandas.util.testing as tm -class TestSparseList(unittest.TestCase): +class TestSparseList(tm.TestCase): def setup_method(self, method): self.na_data = np.array([nan, nan, 1, 2, 3, nan, 4, 5, nan, 6]) diff --git a/pandas/tests/test_config.py b/pandas/tests/test_config.py index 66e0a5a20cf78c..79475b297f83ca 100644 --- a/pandas/tests/test_config.py +++ b/pandas/tests/test_config.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- import pytest +import pandas.util.testing as tm import pandas as pd -import unittest + import warnings -class TestConfig(unittest.TestCase): +class TestConfig(tm.TestCase): def __init__(self, *args): super(TestConfig, self).__init__(*args) diff --git a/pandas/tests/test_testing.py b/pandas/tests/test_testing.py index 2c0cd55205a5a6..2e84638533820a 100644 --- a/pandas/tests/test_testing.py +++ b/pandas/tests/test_testing.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import pandas as pd -import unittest import pytest import numpy as np import sys @@ -340,7 +339,7 @@ def test_assert_almost_equal_iterable_message(self): assert_almost_equal([1, 2], [1, 3]) -class TestAssertIndexEqual(unittest.TestCase): +class TestAssertIndexEqual(tm.TestCase): def test_index_equal_message(self): @@ -680,7 +679,7 @@ def test_frame_equal_message(self): by_blocks=True) -class TestAssertCategoricalEqual(unittest.TestCase): +class TestAssertCategoricalEqual(tm.TestCase): def test_categorical_equal_message(self): @@ -718,7 +717,7 @@ def test_categorical_equal_message(self): tm.assert_categorical_equal(a, b) -class TestRNGContext(unittest.TestCase): +class TestRNGContext(tm.TestCase): def test_RNGContext(self): expected0 = 1.764052345967664 diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index c17a92068b95c7..5436f3c3420198 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -559,11 +559,11 @@ def test_deprecations(self): mom.rolling_mean(Series(np.ones(10)), 3, center=True, axis=0) -# GH #12373 : rolling functions error on float32 data +# gh-12373 : rolling functions error on float32 data # make sure rolling functions works for different dtypes # # NOTE that these are yielded tests and so _create_data is -# explicity called, nor do these inherit from unittest.TestCase +# explicity called, nor do these inherit from tm.TestCase # # further note that we are only checking rolling for fully dtype # compliance (though both expanding and ewm inherit)