Hello community,

here is the log from the commit of package python-SQLAlchemy-Utils for 
openSUSE:Factory checked in at 2017-11-15 16:58:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-SQLAlchemy-Utils (Old)
 and      /work/SRC/openSUSE:Factory/.python-SQLAlchemy-Utils.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-SQLAlchemy-Utils"

Wed Nov 15 16:58:07 2017 rev:7 rq:541231 version:0.32.21

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-SQLAlchemy-Utils/python-SQLAlchemy-Utils.changes
  2017-11-08 15:10:17.905687117 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-SQLAlchemy-Utils.new/python-SQLAlchemy-Utils.changes
     2017-11-15 16:58:15.107040572 +0100
@@ -1,0 +2,11 @@
+Mon Nov 13 04:55:56 UTC 2017 - [email protected]
+
+- update to version 0.32.21:
+  * Close connections on exists, create and drop database functions
+    (#295, pull request courtesy of Terseus)
+
+- changes from version 0.32.20 :
+  * Added __hash__ method for choice objects (#294, pull request
+    courtesy of havelock)
+
+-------------------------------------------------------------------

Old:
----
  SQLAlchemy-Utils-0.32.19.tar.gz

New:
----
  SQLAlchemy-Utils-0.32.21.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-SQLAlchemy-Utils.spec ++++++
--- /var/tmp/diff_new_pack.diw3U0/_old  2017-11-15 16:58:16.722981367 +0100
+++ /var/tmp/diff_new_pack.diw3U0/_new  2017-11-15 16:58:16.726981221 +0100
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-SQLAlchemy-Utils
-Version:        0.32.19
+Version:        0.32.21
 Release:        0
 Summary:        Various utility functions for SQLAlchemy
 License:        BSD-3-Clause

++++++ SQLAlchemy-Utils-0.32.19.tar.gz -> SQLAlchemy-Utils-0.32.21.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.32.19/.isort.cfg 
new/SQLAlchemy-Utils-0.32.21/.isort.cfg
--- old/SQLAlchemy-Utils-0.32.19/.isort.cfg     2016-01-20 08:23:47.000000000 
+0100
+++ new/SQLAlchemy-Utils-0.32.21/.isort.cfg     2017-11-11 18:53:06.000000000 
+0100
@@ -1,5 +1,6 @@
 [settings]
 known_first_party=sqlalchemy_utils
+known_third_party=flexmock
 line_length=79
 multi_line_output=3
 not_skip=__init__.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.32.19/CHANGES.rst 
new/SQLAlchemy-Utils-0.32.21/CHANGES.rst
--- old/SQLAlchemy-Utils-0.32.19/CHANGES.rst    2017-10-17 10:34:46.000000000 
+0200
+++ new/SQLAlchemy-Utils-0.32.21/CHANGES.rst    2017-11-11 18:53:06.000000000 
+0100
@@ -4,6 +4,18 @@
 Here you can see the full list of changes between each SQLAlchemy-Utils 
release.
 
 
+0.32.21 (2017-11-11)
+^^^^^^^^^^^^^^^^^^^^
+
+- Close connections on exists, create and drop database functions (#295, pull 
request courtesy of Terseus)
+
+
+0.32.20 (2017-11-04)
+^^^^^^^^^^^^^^^^^^^^
+
+- Added `__hash__` method for choice objects (#294, pull request courtesy of 
havelock)
+
+
 0.32.19 (2017-10-17)
 ^^^^^^^^^^^^^^^^^^^^
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.32.19/PKG-INFO 
new/SQLAlchemy-Utils-0.32.21/PKG-INFO
--- old/SQLAlchemy-Utils-0.32.19/PKG-INFO       2017-10-17 10:44:09.000000000 
+0200
+++ new/SQLAlchemy-Utils-0.32.21/PKG-INFO       2017-11-11 19:41:23.000000000 
+0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: SQLAlchemy-Utils
-Version: 0.32.19
+Version: 0.32.21
 Summary: Various utility functions for SQLAlchemy.
 Home-page: https://github.com/kvesteri/sqlalchemy-utils
 Author: Konsta Vesterinen, Ryan Leckey, Janne Vanhala, Vesa Uimonen
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/SQLAlchemy_Utils.egg-info/PKG-INFO 
new/SQLAlchemy-Utils-0.32.21/SQLAlchemy_Utils.egg-info/PKG-INFO
--- old/SQLAlchemy-Utils-0.32.19/SQLAlchemy_Utils.egg-info/PKG-INFO     
2017-10-17 10:44:09.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/SQLAlchemy_Utils.egg-info/PKG-INFO     
2017-11-11 19:41:23.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: SQLAlchemy-Utils
-Version: 0.32.19
+Version: 0.32.21
 Summary: Various utility functions for SQLAlchemy.
 Home-page: https://github.com/kvesteri/sqlalchemy-utils
 Author: Konsta Vesterinen, Ryan Leckey, Janne Vanhala, Vesa Uimonen
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.32.19/docs/installation.rst 
new/SQLAlchemy-Utils-0.32.21/docs/installation.rst
--- old/SQLAlchemy-Utils-0.32.19/docs/installation.rst  2016-07-17 
22:00:22.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/docs/installation.rst  2017-11-11 
18:53:06.000000000 +0100
@@ -13,6 +13,7 @@
 - cPython 3.3
 - cPython 3.4
 - cPython 3.5
+- cPython 3.6
 
 
 Installing an official release
@@ -21,7 +22,7 @@
 You can install the most recent official SQLAlchemy-Utils version using
 pip_::
 
-    pip install sqlalchemy-utils
+    pip install sqlalchemy-utils    # Use `pip3` instead of `pip` for Python 
3.x
 
 .. _pip: http://www.pip-installer.org/
 
@@ -33,11 +34,10 @@
 
     git clone git://github.com/kvesteri/sqlalchemy-utils.git
 
-Then you can install the source distribution using the ``setup.py``
-script::
+Then you can install the source distribution using pip::
 
     cd sqlalchemy-utils
-    python setup.py install
+    pip install -e .    # Use `pip3` instead of `pip` for Python 3.x
 
 .. _git: http://git-scm.org/
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/__init__.py 
new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/__init__.py
--- old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/__init__.py   2017-10-17 
10:35:09.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/__init__.py   2017-11-11 
18:53:06.000000000 +0100
@@ -95,4 +95,4 @@
     WeekDaysType
 )
 
-__version__ = '0.32.19'
+__version__ = '0.32.21'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/functions/database.py 
new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/functions/database.py
--- old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/functions/database.py 
2017-10-06 09:16:18.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/functions/database.py 
2017-11-11 18:05:01.000000000 +0100
@@ -451,6 +451,13 @@
 
     """
 
+    def get_scalar_result(engine, sql):
+        result_proxy = engine.execute(sql)
+        result = result_proxy.scalar()
+        result_proxy.close()
+        engine.dispose()
+        return result
+
     url = copy(make_url(url))
     database = url.database
     if url.drivername.startswith('postgres'):
@@ -462,12 +469,12 @@
 
     if engine.dialect.name == 'postgresql':
         text = "SELECT 1 FROM pg_database WHERE datname='%s'" % database
-        return bool(engine.execute(text).scalar())
+        return bool(get_scalar_result(engine, text))
 
     elif engine.dialect.name == 'mysql':
         text = ("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA "
                 "WHERE SCHEMA_NAME = '%s'" % database)
-        return bool(engine.execute(text).scalar())
+        return bool(get_scalar_result(engine, text))
 
     elif engine.dialect.name == 'sqlite':
         if database:
@@ -478,15 +485,21 @@
             return True
 
     else:
+        engine.dispose()
+        engine = None
         text = 'SELECT 1'
         try:
             url.database = database
             engine = sa.create_engine(url)
-            engine.execute(text)
+            result = engine.execute(text)
+            result.close()
             return True
 
         except (ProgrammingError, OperationalError):
             return False
+        finally:
+            if engine is not None:
+                engine.dispose()
 
 
 def create_database(url, encoding='utf8', template=None):
@@ -521,6 +534,7 @@
         url.database = None
 
     engine = sa.create_engine(url)
+    result_proxy = None
 
     if engine.dialect.name == 'postgresql':
         if engine.driver == 'psycopg2':
@@ -537,14 +551,14 @@
             encoding,
             quote(engine, template)
         )
-        engine.execute(text)
+        result_proxy = engine.execute(text)
 
     elif engine.dialect.name == 'mysql':
         text = "CREATE DATABASE {0} CHARACTER SET = '{1}'".format(
             quote(engine, database),
             encoding
         )
-        engine.execute(text)
+        result_proxy = engine.execute(text)
 
     elif engine.dialect.name == 'sqlite' and database != ':memory:':
         if database:
@@ -552,7 +566,11 @@
 
     else:
         text = 'CREATE DATABASE {0}'.format(quote(engine, database))
-        engine.execute(text)
+        result_proxy = engine.execute(text)
+
+    if result_proxy is not None:
+        result_proxy.close()
+    engine.dispose()
 
 
 def drop_database(url):
@@ -578,6 +596,7 @@
         url.database = None
 
     engine = sa.create_engine(url)
+    conn_resource = None
 
     if engine.dialect.name == 'sqlite' and database != ':memory:':
         if database:
@@ -605,6 +624,11 @@
         # Drop the database.
         text = 'DROP DATABASE {0}'.format(quote(connection, database))
         connection.execute(text)
+        conn_resource = connection
     else:
         text = 'DROP DATABASE {0}'.format(quote(engine, database))
-        engine.execute(text)
+        conn_resource = engine.execute(text)
+
+    if conn_resource is not None:
+        conn_resource.close()
+    engine.dispose()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/functions/mock.py 
new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/functions/mock.py
--- old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/functions/mock.py     
2016-04-25 16:20:06.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/functions/mock.py     
2017-11-11 18:05:01.000000000 +0100
@@ -82,7 +82,7 @@
             target = frame.f_locals['__target']
             break
 
-        except:
+        except Exception:
             pass
 
     else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/functions/render.py 
new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/functions/render.py
--- old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/functions/render.py   
2016-04-25 16:20:06.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/functions/render.py   
2017-11-11 18:05:01.000000000 +0100
@@ -37,7 +37,7 @@
             local['engine'] = engine
             six.exec_(expression, frame.f_globals, local)
             break
-        except:
+        except Exception:
             pass
     else:
         raise ValueError('Not a valid python expression', engine)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/types/arrow.py 
new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/types/arrow.py
--- old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/types/arrow.py        
2016-05-11 13:24:06.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/types/arrow.py        
2017-11-11 18:05:01.000000000 +0100
@@ -12,7 +12,7 @@
 arrow = None
 try:
     import arrow
-except:
+except ImportError:
     pass
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/types/choice.py 
new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/types/choice.py
--- old/SQLAlchemy-Utils-0.32.19/sqlalchemy_utils/types/choice.py       
2016-04-25 16:20:06.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/sqlalchemy_utils/types/choice.py       
2017-11-05 16:23:59.000000000 +0100
@@ -20,6 +20,9 @@
             return self.code == other.code
         return other == self.code
 
+    def __hash__(self):
+        return hash(self.code)
+
     def __ne__(self, other):
         return not (self == other)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/tests/functions/test_database.py 
new/SQLAlchemy-Utils-0.32.21/tests/functions/test_database.py
--- old/SQLAlchemy-Utils-0.32.19/tests/functions/test_database.py       
2016-04-25 16:20:06.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/tests/functions/test_database.py       
2017-11-11 18:05:01.000000000 +0100
@@ -99,3 +99,22 @@
             postgresql_db_user
         )
         create_database(dsn, template='my-template')
+
+
+class TestDatabasePostgresCreateDatabaseCloseConnection(object):
+    def test_create_database_twice(self, postgresql_db_user):
+        dsn_list = [
+            'postgres://{0}@localhost/db_test_sqlalchemy-util-a'.format(
+                postgresql_db_user
+            ),
+            'postgres://{0}@localhost/db_test_sqlalchemy-util-b'.format(
+                postgresql_db_user
+            ),
+        ]
+        for dsn_item in dsn_list:
+            assert not database_exists(dsn_item)
+            create_database(dsn_item, template="template1")
+            assert database_exists(dsn_item)
+        for dsn_item in dsn_list:
+            drop_database(dsn_item)
+            assert not database_exists(dsn_item)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.32.19/tests/types/test_choice.py 
new/SQLAlchemy-Utils-0.32.21/tests/types/test_choice.py
--- old/SQLAlchemy-Utils-0.32.19/tests/types/test_choice.py     2016-04-25 
16:20:07.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/tests/types/test_choice.py     2017-11-05 
16:23:59.000000000 +0100
@@ -16,6 +16,9 @@
         assert Choice(1, 1) != 2
         assert not (Choice(1, 1) != 1)
 
+    def test_hash(self):
+        assert hash(Choice(1, 1)) == hash(1)
+
 
 class TestChoiceType(object):
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.32.19/tests/types/test_phonenumber.py 
new/SQLAlchemy-Utils-0.32.21/tests/types/test_phonenumber.py
--- old/SQLAlchemy-Utils-0.32.19/tests/types/test_phonenumber.py        
2016-10-20 08:53:21.000000000 +0200
+++ new/SQLAlchemy-Utils-0.32.21/tests/types/test_phonenumber.py        
2017-11-11 18:53:06.000000000 +0100
@@ -9,28 +9,15 @@
     types
 )
 
-
[email protected]
-def valid_phone_numbers():
-    return [
-        '040 1234567',
-        '+358 401234567',
-        '09 2501234',
-        '+358 92501234',
-        '0800 939393',
-        '09 4243 0456',
-        '0600 900 500'
-    ]
-
-
[email protected]
-def invalid_phone_numbers():
-    return [
-        'abc',
-        '+040 1234567',
-        '0111234567',
-        '358'
-    ]
+VALID_PHONE_NUMBERS = (
+    '040 1234567',
+    '+358 401234567',
+    '09 2501234',
+    '+358 92501234',
+    '0800 939393',
+    '09 4243 0456',
+    '0600 900 500'
+)
 
 
 @pytest.fixture
@@ -69,35 +56,33 @@
 @pytest.mark.skipif('types.phone_number.phonenumbers is None')
 class TestPhoneNumber(object):
 
-    def test_valid_phone_numbers(self, valid_phone_numbers):
-        for raw_number in valid_phone_numbers:
-            number = PhoneNumber(raw_number, 'FI')
-            assert number.is_valid_number()
-
-    def test_invalid_phone_numbers(self, invalid_phone_numbers):
-        for raw_number in invalid_phone_numbers:
-            try:
-                number = PhoneNumber(raw_number, 'FI')
-                assert not number.is_valid_number()
-            except:
-                pass
+    @pytest.mark.parametrize('raw_number', VALID_PHONE_NUMBERS)
+    def test_valid_phone_numbers(self, raw_number):
+        number = PhoneNumber(raw_number, 'FI')
+        assert number.is_valid_number()
+
+    @pytest.mark.parametrize('raw_number', ('abc', '+040 1234567'))
+    def test_invalid_phone_numbers__constructor_fails(self, raw_number):
+        with pytest.raises(PhoneNumberParseException):
+            PhoneNumber(raw_number, 'FI')
+
+    @pytest.mark.parametrize('raw_number', ('0111234567', '358'))
+    def test_invalid_phone_numbers__is_valid_number(self, raw_number):
+        number = PhoneNumber(raw_number, 'FI')
+        assert not number.is_valid_number()
 
     def test_invalid_phone_numbers_throw_dont_wrap_exception(
         self,
         session,
         User
     ):
-        try:
+        with pytest.raises(PhoneNumberParseException):
             session.execute(
                 User.__table__.insert().values(
                     name=u'Someone',
                     phone_number=u'abc'
                 )
             )
-        except PhoneNumberParseException:
-            pass
-        except:
-            assert False
 
     def test_phone_number_attributes(self):
         number = PhoneNumber('+358401234567')


Reply via email to