-
-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix convert_unicode deprecation warning
- Loading branch information
Showing
4 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
from packaging import version | ||
import sqlalchemy | ||
|
||
|
||
def sqlalchemy_version(op, val): | ||
sa_ver = version.parse(sqlalchemy.__version__) | ||
target_ver = version.parse(val) | ||
|
||
assert op in ('<', '>', '<=', '>=', '=='), 'op {} not supported'.format(op) | ||
|
||
if op == '<': | ||
return sa_ver < target_ver | ||
if op == '>': | ||
return sa_ver > target_ver | ||
if op == '<=': | ||
return sa_ver <= target_ver | ||
if op == '>=': | ||
return sa_ver >= target_ver | ||
return sa_ver == target_ver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import mock | ||
|
||
from flask_sqlalchemy import utils | ||
|
||
|
||
class TestSQLAlchemyVersion: | ||
|
||
@mock.patch.object(utils, 'sqlalchemy') | ||
def test_sqlalchemy_version(self, m_sqlalchemy): | ||
m_sqlalchemy.__version__ = '1.3' | ||
|
||
assert not utils.sqlalchemy_version('<', '1.3') | ||
assert not utils.sqlalchemy_version('>', '1.3') | ||
assert utils.sqlalchemy_version('<=', '1.3') | ||
assert utils.sqlalchemy_version('==', '1.3') | ||
assert utils.sqlalchemy_version('>=', '1.3') | ||
|
||
m_sqlalchemy.__version__ = '1.2.99' | ||
|
||
assert utils.sqlalchemy_version('<', '1.3') | ||
assert not utils.sqlalchemy_version('>', '1.3') | ||
assert utils.sqlalchemy_version('<=', '1.3') | ||
assert not utils.sqlalchemy_version('==', '1.3') | ||
assert not utils.sqlalchemy_version('>=', '1.3') |