Skip to content

Commit ff68de5

Browse files
Try this approach
1 parent 7823be2 commit ff68de5

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

Diff for: appveyor.yml

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
environment:
22
matrix:
3+
- PYTHON: "C:\\Python27"
4+
- PYTHON: "C:\\Python27-x64"
5+
- PYTHON: "C:\\Python34"
6+
- PYTHON: "C:\\Python34-x64"
7+
- PYTHON: "C:\\Python35"
8+
- PYTHON: "C:\\Python35-x64"
9+
- PYTHON: "C:\\Python36"
10+
- PYTHON: "C:\\Python36-x64"
311
- PYTHON: "C:\\Python37"
412
- PYTHON: "C:\\Python37-x64"
513
- PYTHON: "C:\\Python38"

Diff for: tarantool/__init__.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
22
# pylint: disable=C0301,W0105,W0401,W0614
33

4+
import sys
45
from tarantool.connection import Connection
56
from tarantool.mesh_connection import MeshConnection
6-
from tarantool.connection_pool import ConnectionPool, Mode
77
from tarantool.const import (
88
SOCKET_TIMEOUT,
99
RECONNECT_MAX_ATTEMPTS,
@@ -76,5 +76,9 @@ def connectmesh(addrs=({'host': 'localhost', 'port': 3301},), user=None,
7676

7777
__all__ = ['connect', 'Connection', 'connectmesh', 'MeshConnection', 'Schema',
7878
'Error', 'DatabaseError', 'NetworkError', 'NetworkWarning',
79-
'SchemaError', 'ConnectionPool',
80-
'Mode', 'dbapi']
79+
'SchemaError', 'dbapi']
80+
81+
# ConnectionPool is supported only for Python 3.7 or newer.
82+
if sys.version_info.major >= 3 and sys.version_info.minor >= 7:
83+
from tarantool.connection_pool import ConnectionPool, Mode
84+
__all__.extend(['ConnectionPool', 'Mode'])

Diff for: test/suites/lib/skip.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ def wrapper(self, *args, **kwargs):
3434
return wrapper
3535

3636

37-
def skip_or_run_test_python_major(func, REQUIRED_PYTHON_MAJOR, msg):
38-
"""Decorator to skip or run tests depending on the Python major
39-
version.
37+
def skip_or_run_test_python(func, REQUIRED_PYTHON_VERSION, msg):
38+
"""Decorator to skip or run tests depending on the Python version.
4039
4140
Also, it can be used with the 'setUp' method for skipping
4241
the whole test suite.
@@ -47,9 +46,12 @@ def wrapper(self, *args, **kwargs):
4746
if func.__name__ == 'setUp':
4847
func(self, *args, **kwargs)
4948

50-
major = sys.version_info.major
51-
if major != REQUIRED_PYTHON_MAJOR:
52-
self.skipTest('Python %s connector %s' % (major, msg))
49+
ver = sys.version_info
50+
python_version_str = '%d.%d' % (ver.major, ver.minor)
51+
python_version = pkg_resources.parse_version(python_version_str)
52+
support_version = pkg_resources.parse_version(REQUIRED_PYTHON_VERSION)
53+
if python_version < support_version:
54+
self.skipTest('Python %s connector %s' % (python_version, msg))
5355

5456
if func.__name__ != 'setUp':
5557
func(self, *args, **kwargs)
@@ -88,4 +90,15 @@ def skip_or_run_mp_bin_test(func):
8890
Python 2 connector do not support mp_bin.
8991
"""
9092

91-
return skip_or_run_test_python_major(func, 3, 'does not support mp_bin')
93+
return skip_or_run_test_python(func, '3.0', 'does not support mp_bin')
94+
95+
96+
def skip_or_run_conn_pool_test(func):
97+
"""Decorator to skip or run mp_bin-related tests depending on
98+
the Python version.
99+
100+
Python 2 connector do not support mp_bin.
101+
"""
102+
103+
return skip_or_run_test_python(func, '3.7',
104+
'does not support ConnectionPool')

Diff for: test/suites/test_pool.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import tarantool
1212
from tarantool.error import ClusterTolopogyError, DatabaseError, NetworkError
1313

14+
from .lib.skip import skip_or_run_conn_pool_test
1415
from .lib.tarantool_server import TarantoolServer
1516

1617

@@ -71,6 +72,7 @@ def setUpClass(self):
7172
print(' POOL '.center(70, '='), file=sys.stderr)
7273
print('-' * 70, file=sys.stderr)
7374

75+
@skip_or_run_conn_pool_test
7476
def setUp(self):
7577
# Create five servers and extract helpful fields for tests.
7678
self.servers = []

0 commit comments

Comments
 (0)