File tree 3 files changed +48
-1
lines changed
3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change
1
+ import functools
2
+ import pkg_resources
3
+ import re
4
+
5
+ SQL_SUPPORT_TNT_VERSION = '2.0.0'
6
+
7
+
8
+ def skip_or_run_sql_test (func ):
9
+ """Decorator to skip or run SQL-related tests depending on the tarantool
10
+ version.
11
+
12
+ Tarantool supports SQL-related stuff only since 2.0.0 version. So this
13
+ decorator should wrap every SQL-related test to skip it if the tarantool
14
+ version < 2.0.0 is used for testing.
15
+
16
+ Also, it can be used with the 'setUp' method for skipping the whole test
17
+ suite.
18
+ """
19
+
20
+ @functools .wraps (func )
21
+ def wrapper (self , * args , ** kwargs ):
22
+ if func .__name__ == 'setUp' :
23
+ func (self , * args , ** kwargs )
24
+
25
+ if not hasattr (self , 'tnt_version' ):
26
+ self .__class__ .tnt_version = re .match (
27
+ r'[\d.]+' , self .srv .admin ('box.info.version' )[0 ]
28
+ ).group ()
29
+
30
+ tnt_version = pkg_resources .parse_version (self .tnt_version )
31
+ sql_support_tnt_version = pkg_resources .parse_version (
32
+ SQL_SUPPORT_TNT_VERSION
33
+ )
34
+
35
+ if tnt_version < sql_support_tnt_version :
36
+ self .skipTest (
37
+ 'Tarantool %s does not support SQL' % self .tnt_version
38
+ )
39
+
40
+ if func .__name__ != 'setUp' :
41
+ func (self , * args , ** kwargs )
42
+
43
+ return wrapper
Original file line number Diff line number Diff line change 10
10
import tarantool
11
11
from tarantool import dbapi
12
12
from .lib .tarantool_server import TarantoolServer
13
+ from .lib .skip import skip_or_run_sql_test
13
14
14
15
15
16
class TestSuite_DBAPI (dbapi20 .DatabaseAPI20Test ):
@@ -34,6 +35,7 @@ def setUpClass(self):
34
35
host = self .srv .host ,
35
36
port = self .srv .args ['primary' ])
36
37
38
+ @skip_or_run_sql_test
37
39
def setUp (self ):
38
40
# prevent a remote tarantool from clean our session
39
41
if self .srv .is_started ():
Original file line number Diff line number Diff line change 7
7
8
8
import tarantool
9
9
from .lib .tarantool_server import TarantoolServer
10
+ from .lib .skip import skip_or_run_sql_test
10
11
11
12
12
13
class TestSuite_Execute (unittest .TestCase ):
13
14
ddl = 'create table %s (id INTEGER PRIMARY KEY AUTOINCREMENT, ' \
14
- 'name varchar(20))'
15
+ 'name varchar(20))'
15
16
16
17
dml_params = [
17
18
{'id' : None , 'name' : 'Michael' },
@@ -30,6 +31,7 @@ def setUpClass(self):
30
31
self .srv .start ()
31
32
self .con = tarantool .Connection (self .srv .host , self .srv .args ['primary' ])
32
33
34
+ @skip_or_run_sql_test
33
35
def setUp (self ):
34
36
# prevent a remote tarantool from clean our session
35
37
if self .srv .is_started ():
You can’t perform that action at this time.
0 commit comments