Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecation warnings #373

Merged
merged 4 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sqlalchemy.ext.declarative import declarative_base, synonym_for
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.session import close_all_sessions
from sqlalchemy_utils import (
aggregates,
coercion_listener,
Expand Down Expand Up @@ -54,7 +55,7 @@ def mysql_db_user():

@pytest.fixture
def postgresql_dsn(postgresql_db_user, db_name):
return 'postgres://{0}@localhost/{1}'.format(postgresql_db_user, db_name)
return 'postgresql://{0}@localhost/{1}'.format(postgresql_db_user, db_name)


@pytest.fixture
Expand Down Expand Up @@ -218,7 +219,7 @@ def session(request, engine, connection, Base, init_models):

def teardown():
aggregates.manager.reset()
session.close_all()
close_all_sessions()
Base.metadata.drop_all(connection)
remove_composite_listeners()
connection.close()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_version():
'psycopg2>=2.5.1',
'pg8000>=1.12.4',
'pytz>=2014.2',
'python-dateutil>=2.2',
'python-dateutil>=2.6',
'pymysql',
'flake8>=2.4.0',
'isort>=4.2.2',
Expand Down
12 changes: 6 additions & 6 deletions sqlalchemy_utils/functions/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,13 @@ def database_exists(url):
Performs backend-specific testing to quickly determine if a database
exists on the server. ::

database_exists('postgres://postgres@localhost/name') #=> False
create_database('postgres://postgres@localhost/name')
database_exists('postgres://postgres@localhost/name') #=> True
database_exists('postgresql://postgres@localhost/name') #=> False
create_database('postgresql://postgres@localhost/name')
database_exists('postgresql://postgres@localhost/name') #=> True

Supports checking against a constructed URL as well. ::

engine = create_engine('postgres://postgres@localhost/name')
engine = create_engine('postgresql://postgres@localhost/name')
database_exists(engine.url) #=> False
create_database(engine.url)
database_exists(engine.url) #=> True
Expand Down Expand Up @@ -523,7 +523,7 @@ def create_database(url, encoding='utf8', template=None):
To create a database, you can pass a simple URL that would have
been passed to ``create_engine``. ::

create_database('postgres://postgres@localhost/name')
create_database('postgresql://postgres@localhost/name')

You may also pass the url from an existing engine. ::

Expand Down Expand Up @@ -598,7 +598,7 @@ def drop_database(url):
Works similar to the :ref:`create_database` method in that both url text
and a constructed url are accepted. ::

drop_database('postgres://postgres@localhost/name')
drop_database('postgresql://postgres@localhost/name')
drop_database(engine.url)

"""
Expand Down
4 changes: 2 additions & 2 deletions sqlalchemy_utils/types/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def __init__(self, backend='dateutil'):
if backend == 'dateutil':
try:
from dateutil.tz import tzfile
from dateutil.zoneinfo import gettz
from dateutil.zoneinfo import get_zonefile_instance

self.python_type = tzfile
self._to = gettz
self._to = get_zonefile_instance().zones.get
self._from = lambda x: six.text_type(x._filename)

except ImportError:
Expand Down
8 changes: 4 additions & 4 deletions tests/functions/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_exists_memory(self, dsn):
assert database_exists(dsn)


@pytest.mark.usefixture('sqlite_none_database_dsn')
@pytest.mark.usefixtures('sqlite_none_database_dsn')
class TestDatabaseSQLiteMemoryNoDatabaseString(object):
def test_exists_memory_none_database(self, sqlite_none_database_dsn):
assert database_exists(sqlite_none_database_dsn)
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_template(self, postgresql_db_user):
"TEMPLATE my_template"
)
)
dsn = 'postgres://{0}@localhost/db_test_sqlalchemy_util'.format(
dsn = 'postgresql://{0}@localhost/db_test_sqlalchemy_util'.format(
postgresql_db_user
)
create_database(dsn, template='my_template')
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_template(self, postgresql_db_user):
'TEMPLATE "my-template"'
)
)
dsn = 'postgres://{0}@localhost/db_test_sqlalchemy-util'.format(
dsn = 'postgresql://{0}@localhost/db_test_sqlalchemy-util'.format(
postgresql_db_user
)
create_database(dsn, template='my-template')
Expand All @@ -117,7 +117,7 @@ def test_template(self, postgresql_db_user):
class TestDatabasePostgresCreateDatabaseCloseConnection(object):
def test_create_database_twice(self, postgresql_db_user):
dsn_list = [
'postgres://{0}@localhost/db_test_sqlalchemy-util-a'.format(
'postgresql://{0}@localhost/db_test_sqlalchemy-util-a'.format(
postgresql_db_user
),
'postgres://{0}@localhost/db_test_sqlalchemy-util-b'.format(
Expand Down