Skip to content

Commit

Permalink
Upgraded tests to remove deprecated unittest methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkleehammer committed Aug 15, 2018
1 parent b66904a commit 320fa39
Show file tree
Hide file tree
Showing 15 changed files with 595 additions and 595 deletions.
56 changes: 28 additions & 28 deletions tests2/accesstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,27 @@ def test_different_bindings(self):

def test_drivers(self):
p = pyodbc.drivers()
self.assert_(isinstance(p, list))
self.assertTrue(isinstance(p, list))

def test_datasources(self):
p = pyodbc.dataSources()
self.assert_(isinstance(p, dict))
self.assertTrue(isinstance(p, dict))

def test_getinfo_string(self):
value = self.cnxn.getinfo(pyodbc.SQL_CATALOG_NAME_SEPARATOR)
self.assert_(isinstance(value, str))
self.assertTrue(isinstance(value, str))

def test_getinfo_bool(self):
value = self.cnxn.getinfo(pyodbc.SQL_ACCESSIBLE_TABLES)
self.assert_(isinstance(value, bool))
self.assertTrue(isinstance(value, bool))

def test_getinfo_int(self):
value = self.cnxn.getinfo(pyodbc.SQL_DEFAULT_TXN_ISOLATION)
self.assert_(isinstance(value, (int, long)))
self.assertTrue(isinstance(value, (int, long)))

def test_getinfo_smallint(self):
value = self.cnxn.getinfo(pyodbc.SQL_CONCAT_NULL_BEHAVIOR)
self.assert_(isinstance(value, int))
self.assertTrue(isinstance(value, int))

def _test_strtype(self, sqltype, value, resulttype=None, colsize=None):
"""
Expand Down Expand Up @@ -297,11 +297,11 @@ def test_negative_row_index(self):
self.cursor.execute("create table t1(s varchar(20))")
self.cursor.execute("insert into t1 values(?)", "1")
row = self.cursor.execute("select * from t1").fetchone()
self.assertEquals(row[0], "1")
self.assertEquals(row[-1], "1")
self.assertEqual(row[0], "1")
self.assertEqual(row[-1], "1")

def test_version(self):
self.assertEquals(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.
self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.

#
# date, time, datetime
Expand All @@ -314,7 +314,7 @@ def test_datetime(self):
self.cursor.execute("insert into t1 values (?)", value)

result = self.cursor.execute("select dt from t1").fetchone()[0]
self.assertEquals(value, result)
self.assertEqual(value, result)

#
# ints and floats
Expand All @@ -325,28 +325,28 @@ def test_int(self):
self.cursor.execute("create table t1(n int)")
self.cursor.execute("insert into t1 values (?)", value)
result = self.cursor.execute("select n from t1").fetchone()[0]
self.assertEquals(result, value)
self.assertEqual(result, value)

def test_negative_int(self):
value = -1
self.cursor.execute("create table t1(n int)")
self.cursor.execute("insert into t1 values (?)", value)
result = self.cursor.execute("select n from t1").fetchone()[0]
self.assertEquals(result, value)
self.assertEqual(result, value)

def test_smallint(self):
value = 32767
self.cursor.execute("create table t1(n smallint)")
self.cursor.execute("insert into t1 values (?)", value)
result = self.cursor.execute("select n from t1").fetchone()[0]
self.assertEquals(result, value)
self.assertEqual(result, value)

def test_real(self):
value = 1234.5
self.cursor.execute("create table t1(n real)")
self.cursor.execute("insert into t1 values (?)", value)
result = self.cursor.execute("select n from t1").fetchone()[0]
self.assertEquals(result, value)
self.assertEqual(result, value)

def test_negative_real(self):
value = -200.5
Expand All @@ -360,7 +360,7 @@ def test_float(self):
self.cursor.execute("create table t1(n float)")
self.cursor.execute("insert into t1 values (?)", value)
result = self.cursor.execute("select n from t1").fetchone()[0]
self.assertEquals(result, value)
self.assertEqual(result, value)

def test_negative_float(self):
value = -200.5
Expand Down Expand Up @@ -444,13 +444,13 @@ def test_guid(self):
#

def test_rowcount_delete(self):
self.assertEquals(self.cursor.rowcount, -1)
self.assertEqual(self.cursor.rowcount, -1)
self.cursor.execute("create table t1(i int)")
count = 4
for i in range(count):
self.cursor.execute("insert into t1 values (?)", i)
self.cursor.execute("delete from t1")
self.assertEquals(self.cursor.rowcount, count)
self.assertEqual(self.cursor.rowcount, count)

def test_rowcount_nodata(self):
"""
Expand All @@ -463,7 +463,7 @@ def test_rowcount_nodata(self):
self.cursor.execute("create table t1(i int)")
# This is a different code path internally.
self.cursor.execute("delete from t1")
self.assertEquals(self.cursor.rowcount, 0)
self.assertEqual(self.cursor.rowcount, 0)

def test_rowcount_select(self):
"""
Expand All @@ -478,11 +478,11 @@ def test_rowcount_select(self):
for i in range(count):
self.cursor.execute("insert into t1 values (?)", i)
self.cursor.execute("select * from t1")
self.assertEquals(self.cursor.rowcount, -1)
self.assertEqual(self.cursor.rowcount, -1)

rows = self.cursor.fetchall()
self.assertEquals(len(rows), count)
self.assertEquals(self.cursor.rowcount, -1)
self.assertEqual(len(rows), count)
self.assertEqual(self.cursor.rowcount, -1)

def test_rowcount_reset(self):
"Ensure rowcount is reset to -1"
Expand All @@ -491,10 +491,10 @@ def test_rowcount_reset(self):
count = 4
for i in range(count):
self.cursor.execute("insert into t1 values (?)", i)
self.assertEquals(self.cursor.rowcount, 1)
self.assertEqual(self.cursor.rowcount, 1)

self.cursor.execute("create table t2(i int)")
self.assertEquals(self.cursor.rowcount, -1)
self.assertEqual(self.cursor.rowcount, -1)

#
# Misc
Expand All @@ -514,7 +514,7 @@ def test_lower_case(self):
names = [ t[0] for t in self.cursor.description ]
names.sort()

self.assertEquals(names, [ "abc", "def" ])
self.assertEqual(names, [ "abc", "def" ])

# Put it back so other tests don't fail.
pyodbc.lowercase = False
Expand All @@ -529,7 +529,7 @@ def test_row_description(self):
self.cursor.execute("insert into t1 values(1, 'abc')")

row = self.cursor.execute("select * from t1").fetchone()
self.assertEquals(self.cursor.description, row.cursor_description)
self.assertEqual(self.cursor.description, row.cursor_description)


def test_executemany(self):
Expand Down Expand Up @@ -561,7 +561,7 @@ def test_executemany_failure(self):
('error', 'not an int'),
(3, 'good') ]

self.failUnlessRaises(pyodbc.Error, self.cursor.executemany, "insert into t1(a, b) value (?, ?)", params)
self.assertRaises(pyodbc.Error, self.cursor.executemany, "insert into t1(a, b) value (?, ?)", params)


def test_row_slicing(self):
Expand All @@ -571,13 +571,13 @@ def test_row_slicing(self):
row = self.cursor.execute("select * from t1").fetchone()

result = row[:]
self.failUnless(result is row)
self.assertTrue(result is row)

result = row[:-1]
self.assertEqual(result, (1,2,3))

result = row[0:4]
self.failUnless(result is row)
self.assertTrue(result is row)


def test_row_repr(self):
Expand Down
Loading

0 comments on commit 320fa39

Please sign in to comment.