Skip to content

Commit 530d5e9

Browse files
authored
Merge pull request #134 from madscientist/master
Fix test suite. Update to newer versions in Travis. Bump the release to 2.3.3
2 parents ddc5c0b + 66d5a7a commit 530d5e9

11 files changed

+111
-109
lines changed

.travis.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
dist: xenial
2+
13
language: python
24

35
python:
46
- "2.7"
5-
- "3.6"
7+
- "3.7"
68

79
env:
810
global:
@@ -11,8 +13,8 @@ env:
1113
- NUO_ADD_DOMAIN_PASS=yes
1214
- NUO_START_AGENT=yes
1315
matrix:
14-
- NUO_VERSION=3.1.2.1
15-
- NUO_VERSION=3.2.0.2
16+
- NUO_VERSION=3.2.2.1
17+
- NUO_VERSION=3.3.0.1
1618

1719
notifications:
1820
recipients:
@@ -23,10 +25,6 @@ before_install:
2325
- echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled >/dev/null
2426
- echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/defrag >/dev/null
2527

26-
# There's a bug in the Trusty images where this gives a syntax error
27-
# See https://github.com/travis-ci/travis-ci/issues/8906
28-
- sudo mv /opt/jdk_switcher/jdk_switcher.sh /tmp
29-
3028
- wget -q "http://download.nuohub.org/nuodb-ce_${NUO_VERSION}_amd64.deb" --output-document=/var/tmp/nuodb.deb
3129
- sudo dpkg -i /var/tmp/nuodb.deb
3230

pynuodb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '2.3.2'
1+
__version__ = '2.3.3'
22

33
from .connection import *
44
from .datatype import *

tests/dbapi20.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def test_threadsafety(self):
171171
# Must exist
172172
threadsafety = self.driver.threadsafety
173173
# Must be a valid value
174-
self.failUnless(threadsafety in (0,1,2,3))
174+
self.assertIn(threadsafety, (0,1,2,3))
175175
except AttributeError:
176176
self.fail("Driver doesn't define threadsafety")
177177

@@ -180,7 +180,7 @@ def test_paramstyle(self):
180180
# Must exist
181181
paramstyle = self.driver.paramstyle
182182
# Must be a valid value
183-
self.failUnless(paramstyle in (
183+
self.assertIn(paramstyle, (
184184
'qmark','numeric','named','format','pyformat'
185185
))
186186
except AttributeError:
@@ -189,28 +189,28 @@ def test_paramstyle(self):
189189
def test_Exceptions(self):
190190
# Make sure required exceptions exist, and are in the
191191
# defined heirarchy.
192-
self.failUnless(issubclass(self.driver.Warning,Exception))
193-
self.failUnless(issubclass(self.driver.Error,Exception))
192+
self.assertTrue(issubclass(self.driver.Warning,Exception))
193+
self.assertTrue(issubclass(self.driver.Error,Exception))
194194

195-
self.failUnless(
195+
self.assertTrue(
196196
issubclass(self.driver.InterfaceError,self.driver.Error)
197197
)
198-
self.failUnless(
198+
self.assertTrue(
199199
issubclass(self.driver.DatabaseError,self.driver.Error)
200200
)
201-
self.failUnless(
201+
self.assertTrue(
202202
issubclass(self.driver.OperationalError,self.driver.Error)
203203
)
204-
self.failUnless(
204+
self.assertTrue(
205205
issubclass(self.driver.IntegrityError,self.driver.Error)
206206
)
207-
self.failUnless(
207+
self.assertTrue(
208208
issubclass(self.driver.InternalError,self.driver.Error)
209209
)
210-
self.failUnless(
210+
self.assertTrue(
211211
issubclass(self.driver.ProgrammingError,self.driver.Error)
212212
)
213-
self.failUnless(
213+
self.assertTrue(
214214
issubclass(self.driver.NotSupportedError,self.driver.Error)
215215
)
216216

@@ -223,15 +223,15 @@ def test_ExceptionsAsConnectionAttributes(self):
223223
# by default.
224224
con = self._connect()
225225
drv = self.driver
226-
self.failUnless(con.Warning is drv.Warning)
227-
self.failUnless(con.Error is drv.Error)
228-
self.failUnless(con.InterfaceError is drv.InterfaceError)
229-
self.failUnless(con.DatabaseError is drv.DatabaseError)
230-
self.failUnless(con.OperationalError is drv.OperationalError)
231-
self.failUnless(con.IntegrityError is drv.IntegrityError)
232-
self.failUnless(con.InternalError is drv.InternalError)
233-
self.failUnless(con.ProgrammingError is drv.ProgrammingError)
234-
self.failUnless(con.NotSupportedError is drv.NotSupportedError)
226+
self.assertIs(con.Warning, drv.Warning)
227+
self.assertIs(con.Error, drv.Error)
228+
self.assertIs(con.InterfaceError, drv.InterfaceError)
229+
self.assertIs(con.DatabaseError, drv.DatabaseError)
230+
self.assertIs(con.OperationalError, drv.OperationalError)
231+
self.assertIs(con.IntegrityError, drv.IntegrityError)
232+
self.assertIs(con.InternalError, drv.InternalError)
233+
self.assertIs(con.ProgrammingError, drv.ProgrammingError)
234+
self.assertIs(con.NotSupportedError, drv.NotSupportedError)
235235

236236

237237
def test_commit(self):
@@ -323,12 +323,12 @@ def test_rowcount(self):
323323
cur.execute("insert into %sbooze values ('Victoria Bitter')" % (
324324
self.table_prefix
325325
))
326-
self.failUnless(cur.rowcount in (-1,1),
326+
self.assertIn(cur.rowcount, (-1,1),
327327
'cursor.rowcount should == number or rows inserted, or '
328328
'set to -1 after executing an insert statement'
329329
)
330330
cur.execute("select name from %sbooze" % self.table_prefix)
331-
self.failUnless(cur.rowcount in (-1,1),
331+
self.assertIn(cur.rowcount, (-1,1),
332332
'cursor.rowcount should == number of rows returned, or '
333333
'set to -1 after executing a select statement'
334334
)
@@ -391,7 +391,7 @@ def _paraminsert(self,cur):
391391
cur.execute("insert into %sbooze values ('Victoria Bitter')" % (
392392
self.table_prefix
393393
))
394-
self.failUnless(cur.rowcount in (-1,1))
394+
self.assertIn(cur.rowcount, (-1,1))
395395

396396
if self.driver.paramstyle == 'qmark':
397397
cur.execute(
@@ -420,7 +420,7 @@ def _paraminsert(self,cur):
420420
)
421421
else:
422422
self.fail('Invalid paramstyle')
423-
self.failUnless(cur.rowcount in (-1,1))
423+
self.assertIn(cur.rowcount, (-1,1))
424424

425425
cur.execute('select name from %sbooze' % self.table_prefix)
426426
res = cur.fetchall()
@@ -471,7 +471,7 @@ def test_executemany(self):
471471
)
472472
else:
473473
self.fail('Unknown paramstyle')
474-
self.failUnless(cur.rowcount in (-1,2),
474+
self.assertIn(cur.rowcount, (-1,2),
475475
'insert using cursor.executemany set cursor.rowcount to '
476476
'incorrect value %r' % cur.rowcount
477477
)
@@ -506,7 +506,7 @@ def test_fetchone(self):
506506
'cursor.fetchone should return None if a query retrieves '
507507
'no rows'
508508
)
509-
self.failUnless(cur.rowcount in (-1,0))
509+
self.assertIn(cur.rowcount, (-1,0))
510510

511511
# cursor.fetchone should raise an Error if called after
512512
# executing a query that cannnot return rows
@@ -526,7 +526,7 @@ def test_fetchone(self):
526526
self.assertEqual(cur.fetchone(),None,
527527
'cursor.fetchone should return None if no more rows available'
528528
)
529-
self.failUnless(cur.rowcount in (-1,1))
529+
self.assertIn(cur.rowcount, (-1,1))
530530
finally:
531531
con.close()
532532

@@ -582,7 +582,7 @@ def test_fetchmany(self):
582582
'cursor.fetchmany should return an empty sequence after '
583583
'results are exhausted'
584584
)
585-
self.failUnless(cur.rowcount in (-1,6))
585+
self.assertIn(cur.rowcount, (-1,6))
586586

587587
# Same as above, using cursor.arraysize
588588
cur.arraysize=4
@@ -595,12 +595,12 @@ def test_fetchmany(self):
595595
self.assertEqual(len(r),2)
596596
r = cur.fetchmany() # Should be an empty sequence
597597
self.assertEqual(len(r),0)
598-
self.failUnless(cur.rowcount in (-1,6))
598+
self.assertIn(cur.rowcount, (-1,6))
599599

600600
cur.arraysize=6
601601
cur.execute('select name from %sbooze' % self.table_prefix)
602602
rows = cur.fetchmany() # Should get all rows
603-
self.failUnless(cur.rowcount in (-1,6))
603+
self.assertIn(cur.rowcount, (-1,6))
604604
self.assertEqual(len(rows),6)
605605
self.assertEqual(len(rows),6)
606606
rows = [r[0] for r in rows]
@@ -617,7 +617,7 @@ def test_fetchmany(self):
617617
'cursor.fetchmany should return an empty sequence if '
618618
'called after the whole result set has been fetched'
619619
)
620-
self.failUnless(cur.rowcount in (-1,6))
620+
self.assertIn(cur.rowcount, (-1,6))
621621

622622
self.executeDDL2(cur)
623623
cur.execute('select name from %sbarflys' % self.table_prefix)
@@ -626,7 +626,7 @@ def test_fetchmany(self):
626626
'cursor.fetchmany should return an empty sequence if '
627627
'query retrieved no rows'
628628
)
629-
self.failUnless(cur.rowcount in (-1,0))
629+
self.assertIn(cur.rowcount, (-1,0))
630630

631631
finally:
632632
con.close()
@@ -650,7 +650,7 @@ def test_fetchall(self):
650650

651651
cur.execute('select name from %sbooze' % self.table_prefix)
652652
rows = cur.fetchall()
653-
self.failUnless(cur.rowcount in (-1,len(self.samples)))
653+
self.assertIn(cur.rowcount, (-1,len(self.samples)))
654654
self.assertEqual(len(rows),len(self.samples),
655655
'cursor.fetchall did not retrieve all rows'
656656
)
@@ -666,12 +666,12 @@ def test_fetchall(self):
666666
'cursor.fetchall should return an empty list if called '
667667
'after the whole result set has been fetched'
668668
)
669-
self.failUnless(cur.rowcount in (-1,len(self.samples)))
669+
self.assertIn(cur.rowcount, (-1,len(self.samples)))
670670

671671
self.executeDDL2(cur)
672672
cur.execute('select name from %sbarflys' % self.table_prefix)
673673
rows = cur.fetchall()
674-
self.failUnless(cur.rowcount in (-1,0))
674+
self.assertIn(cur.rowcount, (-1,0))
675675
self.assertEqual(len(rows),0,
676676
'cursor.fetchall should return an empty list if '
677677
'a select query returns no rows'
@@ -693,7 +693,7 @@ def test_mixedfetch(self):
693693
rows23 = cur.fetchmany(2)
694694
rows4 = cur.fetchone()
695695
rows56 = cur.fetchall()
696-
self.failUnless(cur.rowcount in (-1,6))
696+
self.assertIn(cur.rowcount, (-1,6))
697697
self.assertEqual(len(rows23),2,
698698
'fetchmany returned incorrect number of rows'
699699
)
@@ -772,7 +772,7 @@ def test_arraysize(self):
772772
con = self._connect()
773773
try:
774774
cur = con.cursor()
775-
self.failUnless(hasattr(cur,'arraysize'),
775+
self.assertTrue(hasattr(cur,'arraysize'),
776776
'cursor.arraysize must be defined'
777777
)
778778
finally:
@@ -841,26 +841,26 @@ def test_Binary(self):
841841
b = self.driver.Binary(str2bytes(''))
842842

843843
def test_STRING(self):
844-
self.failUnless(hasattr(self.driver,'STRING'),
844+
self.assertTrue(hasattr(self.driver,'STRING'),
845845
'module.STRING must be defined'
846846
)
847847

848848
def test_BINARY(self):
849-
self.failUnless(hasattr(self.driver,'BINARY'),
849+
self.assertTrue(hasattr(self.driver,'BINARY'),
850850
'module.BINARY must be defined.'
851851
)
852852

853853
def test_NUMBER(self):
854-
self.failUnless(hasattr(self.driver,'NUMBER'),
854+
self.assertTrue(hasattr(self.driver,'NUMBER'),
855855
'module.NUMBER must be defined.'
856856
)
857857

858858
def test_DATETIME(self):
859-
self.failUnless(hasattr(self.driver,'DATETIME'),
859+
self.assertTrue(hasattr(self.driver,'DATETIME'),
860860
'module.DATETIME must be defined.'
861861
)
862862

863863
def test_ROWID(self):
864-
self.failUnless(hasattr(self.driver,'ROWID'),
864+
self.assertTrue(hasattr(self.driver,'ROWID'),
865865
'module.ROWID must be defined.'
866866
)

tests/dbapi20_tpc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def test_xid(self):
2828
except self.driver.NotSupportedError:
2929
self.fail("Driver does not support transaction IDs.")
3030

31-
self.assertEquals(xid[0], 42)
32-
self.assertEquals(xid[1], "global")
33-
self.assertEquals(xid[2], "bqual")
31+
self.assertEqual(xid[0], 42)
32+
self.assertEqual(xid[1], "global")
33+
self.assertEqual(xid[2], "bqual")
3434

3535
# Try some extremes for the transaction ID:
3636
xid = con.xid(0, "", "")
37-
self.assertEquals(tuple(xid), (0, "", ""))
37+
self.assertEqual(tuple(xid), (0, "", ""))
3838
xid = con.xid(0x7fffffff, "a" * 64, "b" * 64)
39-
self.assertEquals(tuple(xid), (0x7fffffff, "a" * 64, "b" * 64))
39+
self.assertEqual(tuple(xid), (0x7fffffff, "a" * 64, "b" * 64))
4040

4141
def test_tpc_begin(self):
4242
con = self.connect()

tests/nuodb_basic_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,16 @@ def _test_faulty_decimal_fixture(self, value, precision, scale):
155155
cursor.execute("DROP TABLE CASCADE t IF EXISTS")
156156
try:
157157
cursor.execute("CREATE TABLE t (x NUMERIC(%s,%s))" % (precision, scale))
158-
DataError
159158
cursor.execute("INSERT INTO t (x) VALUES (?)", (value,))
160159
cursor.execute("SELECT * FROM t")
161160
self.fail("Incorrectly inserted %s as NUMERIC(%s,%s)" % (str(value), str(precision), str(scale)))
162161

163162
except DataError as err:
164-
self.assertIn("CONSTRAINT_ERROR", str(err))
163+
# Older versions of NuoDB would throw a CONSTRAINT_ERROR.
164+
# Newer versions throw a CONVERSION_ERROR.
165+
msg = str(err)
166+
if not 'CONSTRAINT_ERROR' in msg and not 'CONVERSION_ERROR' in msg:
167+
self.fail("Unexpected DataError: %s" % (msg))
165168

166169
finally:
167170
try:

tests/nuodb_blob_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def test_blob_prepared(self):
2323
if systemVersion is '3':
2424
currentRow = bytes(currentRow, 'latin-1')
2525
array2 = unpack('hhl', currentRow)
26-
self.assertEquals(len(array2), 3)
27-
self.assertEquals(array2[2], 3)
26+
self.assertEqual(len(array2), 3)
27+
self.assertEqual(array2[2], 3)
2828

2929

3030
if __name__ == '__main__':

0 commit comments

Comments
 (0)