File tree Expand file tree Collapse file tree 3 files changed +48
-1
lines changed Expand file tree Collapse file tree 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 1010import tarantool
1111from tarantool import dbapi
1212from .lib .tarantool_server import TarantoolServer
13+ from .lib .skip import skip_or_run_sql_test
1314
1415
1516class TestSuite_DBAPI (dbapi20 .DatabaseAPI20Test ):
@@ -34,6 +35,7 @@ def setUpClass(self):
3435 host = self .srv .host ,
3536 port = self .srv .args ['primary' ])
3637
38+ @skip_or_run_sql_test
3739 def setUp (self ):
3840 # prevent a remote tarantool from clean our session
3941 if self .srv .is_started ():
Original file line number Diff line number Diff line change 77
88import tarantool
99from .lib .tarantool_server import TarantoolServer
10+ from .lib .skip import skip_or_run_sql_test
1011
1112
1213class TestSuite_Execute (unittest .TestCase ):
1314 ddl = 'create table %s (id INTEGER PRIMARY KEY AUTOINCREMENT, ' \
14- 'name varchar(20))'
15+ 'name varchar(20))'
1516
1617 dml_params = [
1718 {'id' : None , 'name' : 'Michael' },
@@ -30,6 +31,7 @@ def setUpClass(self):
3031 self .srv .start ()
3132 self .con = tarantool .Connection (self .srv .host , self .srv .args ['primary' ])
3233
34+ @skip_or_run_sql_test
3335 def setUp (self ):
3436 # prevent a remote tarantool from clean our session
3537 if self .srv .is_started ():
You can’t perform that action at this time.
0 commit comments