diff --git a/README.rst b/README.rst index 1696237..51280e2 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ .. image:: https://img.shields.io/coveralls/baztian/jaydebeapi/master.svg :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/ .. image:: https://img.shields.io/badge/jython-2.7.2-blue.svg @@ -96,7 +96,7 @@ Here is an example: >>> curs = conn.cursor() >>> curs.execute('create table CUSTOMER' ... '("CUST_ID" INTEGER not null,' -... ' "NAME" VARCHAR not null,' +... ' "NAME" VARCHAR(50) not null,' ... ' primary key ("CUST_ID"))' ... ) >>> curs.execute("insert into CUSTOMER values (1, 'John')") diff --git a/mockdriver/pom.xml b/mockdriver/pom.xml index 9faf8d2..72cbc88 100644 --- a/mockdriver/pom.xml +++ b/mockdriver/pom.xml @@ -15,8 +15,8 @@ org.mockito - mockito-inline - 3.3.3 + mockito-all + 1.10.19 diff --git a/test/test_integration.py b/test/test_integration.py index a99c69d..c317ce5 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -207,17 +207,6 @@ class IntegrationTestBase(object): cursor.execute("select * from ACCOUNT") 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): def setUpSql(self): @@ -293,10 +282,12 @@ class PropertiesDriverArgsPassingTest(unittest.TestCase): driver, url, driver_args = ( 'org.hsqldb.jdbcDriver', 'jdbc:hsqldb:mem:.', ['SA', ''] ) - jaydebeapi.connect(driver, url, driver_args) + c = jaydebeapi.connect(driver, url, driver_args) + c.close() def test_connect_with_properties(self): driver, url, driver_args = ( 'org.hsqldb.jdbcDriver', 'jdbc:hsqldb:mem:.', {'user': 'SA', 'password': '' } ) - jaydebeapi.connect(driver, url, driver_args) + c = jaydebeapi.connect(driver, url, driver_args) + c.close() diff --git a/test/test_mock.py b/test/test_mock.py index 03977a0..2d44952 100644 --- a/test/test_mock.py +++ b/test/test_mock.py @@ -106,3 +106,16 @@ class MockTest(unittest.TestCase): self.fail("expected exception") except jaydebeapi.InterfaceError as e: 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) diff --git a/tox.ini b/tox.ini index c61e685..5d62205 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ whitelist_externals = mvn setenv = CLASSPATH = {envdir}/javalib/* 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-sqlitePy: TESTNAME=test_integration.SqlitePyTest deps =