Merge branch 'more-test-fixes'. Fixes #144 which acutally was just a testing issue

master
baztian 2020-05-27 22:32:08 +02:00
commit 55c9b44c23
5 changed files with 22 additions and 18 deletions

View File

@ -8,7 +8,7 @@
.. image:: https://img.shields.io/coveralls/baztian/jaydebeapi/master.svg .. image:: https://img.shields.io/coveralls/baztian/jaydebeapi/master.svg
:target: https://coveralls.io/r/baztian/jaydebeapi :target: https://coveralls.io/r/baztian/jaydebeapi
.. image:: https://img.shields.io/badge/python-2.7,_3.4,_3.6-blue.svg .. image:: https://img.shields.io/badge/python-2.7,_3.5,_3.6-blue.svg
:target: https://pypi.python.org/pypi/JayDeBeApi/ :target: https://pypi.python.org/pypi/JayDeBeApi/
.. image:: https://img.shields.io/badge/jython-2.7.2-blue.svg .. image:: https://img.shields.io/badge/jython-2.7.2-blue.svg
@ -96,7 +96,7 @@ Here is an example:
>>> curs = conn.cursor() >>> curs = conn.cursor()
>>> curs.execute('create table CUSTOMER' >>> curs.execute('create table CUSTOMER'
... '("CUST_ID" INTEGER not null,' ... '("CUST_ID" INTEGER not null,'
... ' "NAME" VARCHAR not null,' ... ' "NAME" VARCHAR(50) not null,'
... ' primary key ("CUST_ID"))' ... ' primary key ("CUST_ID"))'
... ) ... )
>>> curs.execute("insert into CUSTOMER values (1, 'John')") >>> curs.execute("insert into CUSTOMER values (1, 'John')")

View File

@ -15,8 +15,8 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId> <artifactId>mockito-all</artifactId>
<version>3.3.3</version> <version>1.10.19</version>
<!-- non-test scope on purpose --> <!-- non-test scope on purpose -->
</dependency> </dependency>
<dependency> <dependency>

View File

@ -207,17 +207,6 @@ class IntegrationTestBase(object):
cursor.execute("select * from ACCOUNT") cursor.execute("select * from ACCOUNT")
self.assertEqual(cursor.rowcount, -1) self.assertEqual(cursor.rowcount, -1)
def test_connection_with_statement(self):
with self.connect() as conn:
self.assertEqual(conn._closed, False)
self.assertEqual(conn._closed, True)
def test_cursor_with_statement(self):
with self.conn.cursor() as cursor:
cursor.execute("select 1 from ACCOUNT")
self.assertIsNotNone(cursor._connection)
self.assertIsNone(cursor._connection)
class SqliteTestBase(IntegrationTestBase): class SqliteTestBase(IntegrationTestBase):
def setUpSql(self): def setUpSql(self):
@ -293,10 +282,12 @@ class PropertiesDriverArgsPassingTest(unittest.TestCase):
driver, url, driver_args = ( 'org.hsqldb.jdbcDriver', driver, url, driver_args = ( 'org.hsqldb.jdbcDriver',
'jdbc:hsqldb:mem:.', 'jdbc:hsqldb:mem:.',
['SA', ''] ) ['SA', ''] )
jaydebeapi.connect(driver, url, driver_args) c = jaydebeapi.connect(driver, url, driver_args)
c.close()
def test_connect_with_properties(self): def test_connect_with_properties(self):
driver, url, driver_args = ( 'org.hsqldb.jdbcDriver', driver, url, driver_args = ( 'org.hsqldb.jdbcDriver',
'jdbc:hsqldb:mem:.', 'jdbc:hsqldb:mem:.',
{'user': 'SA', 'password': '' } ) {'user': 'SA', 'password': '' } )
jaydebeapi.connect(driver, url, driver_args) c = jaydebeapi.connect(driver, url, driver_args)
c.close()

View File

@ -106,3 +106,16 @@ class MockTest(unittest.TestCase):
self.fail("expected exception") self.fail("expected exception")
except jaydebeapi.InterfaceError as e: except jaydebeapi.InterfaceError as e:
self.assertEquals(str(e), "java.lang.RuntimeException: expected") self.assertEquals(str(e), "java.lang.RuntimeException: expected")
def test_cursor_with_statement(self):
self.conn.jconn.mockType("INTEGER")
with self.conn.cursor() as cursor:
cursor.execute("dummy stmt")
self.assertIsNotNone(cursor._connection)
self.assertIsNone(cursor._connection)
def test_connection_with_statement(self):
with jaydebeapi.connect('org.jaydebeapi.mockdriver.MockDriver',
'jdbc:jaydebeapi://dummyurl') as conn:
self.assertEqual(conn._closed, False)
self.assertEqual(conn._closed, True)

View File

@ -14,7 +14,7 @@ whitelist_externals = mvn
setenv = setenv =
CLASSPATH = {envdir}/javalib/* CLASSPATH = {envdir}/javalib/*
driver-mock: TESTNAME=test_mock driver-mock: TESTNAME=test_mock
driver-hsqldb: TESTNAME=test_integration.HsqldbTest driver-hsqldb: TESTNAME=test_integration.HsqldbTest test_integration.PropertiesDriverArgsPassingTest
driver-sqliteXerial: TESTNAME=test_integration.SqliteXerialTest driver-sqliteXerial: TESTNAME=test_integration.SqliteXerialTest
driver-sqlitePy: TESTNAME=test_integration.SqlitePyTest driver-sqlitePy: TESTNAME=test_integration.SqlitePyTest
deps = deps =