Skip to content

Commit ae0d7f7

Browse files
test: run cases for datetime with 2.11 fixes
There were a couple of datetime bugs in core Tarantool [1, 2] in 2.10 that were fixed in 2.11. We had a couple of test cases which were skipped before because of these bugs. After 2.11 we may change these skips to conditional skips. 1. tarantool/tarantool#7698 2. tarantool/tarantool#7700 Closes #246
1 parent e954c4c commit ae0d7f7

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

tarantool/msgpack_ext/types/datetime.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -532,18 +532,6 @@ def __sub__(self, other):
532532
self_dt = self._datetime
533533
other_dt = other._datetime
534534

535-
# Tarantool datetime subtraction ignores timezone info, but it is a bug:
536-
#
537-
# Tarantool 2.10.1-0-g482d91c66
538-
#
539-
# tarantool> datetime.new{tz='MSK'} - datetime.new{tz='UTC'}
540-
# ---
541-
# - +0 seconds
542-
# ...
543-
#
544-
# Refer to https://github.com/tarantool/tarantool/issues/7698
545-
# for possible updates.
546-
547535
if self_dt.tzinfo != other_dt.tzinfo:
548536
other_dt = other_dt.astimezone(self_dt.tzinfo)
549537

test/suites/lib/skip.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,19 @@ def skip_or_run_datetime_test(func):
205205
'does not support datetime type')
206206

207207

208+
def skip_or_run_datetime_2_11_test(func):
209+
"""
210+
Decorator to skip or run tests related to datetime module with
211+
fixes introduced in 2.11 release.
212+
213+
See https://github.com/tarantool/tarantool/issues/7698 and
214+
https://github.com/tarantool/tarantool/issues/7700
215+
"""
216+
217+
return skip_or_run_test_tarantool(func, '2.11.0',
218+
'does not provide required datetime fixes')
219+
220+
208221
def skip_or_run_error_extra_info_test(func):
209222
"""
210223
Decorator to skip or run tests related to extra error info

test/suites/test_datetime.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from tarantool.msgpack_ext.unpacker import ext_hook as unpacker_ext_hook
1616

1717
from .lib.tarantool_server import TarantoolServer
18-
from .lib.skip import skip_or_run_datetime_test
18+
from .lib.skip import skip_or_run_datetime_test, skip_or_run_datetime_2_11_test
1919

2020

2121
class TestSuiteDatetime(unittest.TestCase):
@@ -381,21 +381,23 @@ def test_tarantool_datetime_subtraction(self):
381381
datetime_subtraction_different_timezones_case = {
382382
'arg_1': tarantool.Datetime(year=2001, month=2, day=3, tz='UTC'),
383383
'arg_2': tarantool.Datetime(year=2001, month=2, day=3, tz='MSK'),
384-
'res': tarantool.Interval(day=1, hour=-21),
384+
# Tarantool datetime comparison is naive, our tarantool.Interval comparison is naive too.
385+
# So even though day=1, hour=-21 is the same as minute=180, test assertion fails.
386+
'res_python': tarantool.Interval(day=1, hour=-21),
387+
'res_tarantool': tarantool.Interval(minute=180),
385388
}
386389

387390
def test_python_datetime_subtraction_different_timezones(self):
388391
case = self.datetime_subtraction_different_timezones_case
389392

390-
self.assertEqual(case['arg_1'] - case['arg_2'], case['res'])
393+
self.assertEqual(case['arg_1'] - case['arg_2'], case['res_python'])
391394

392-
@skip_or_run_datetime_test
393-
@unittest.skip('See https://github.com/tarantool/tarantool/issues/7698')
395+
@skip_or_run_datetime_2_11_test
394396
def test_tarantool_datetime_subtraction_different_timezones(self):
395397
case = self.datetime_subtraction_different_timezones_case
396398

397399
self.assertSequenceEqual(self.con.call('sub', case['arg_1'], case['arg_2']),
398-
[case['res']])
400+
[case['res_tarantool']])
399401

400402
interval_arithmetic_cases = {
401403
'year': {
@@ -515,8 +517,7 @@ def test_python_datetime_addition_winter_time_switch(self):
515517

516518
self.assertEqual(case['arg_1'] + case['arg_2'], case['res'])
517519

518-
@skip_or_run_datetime_test
519-
@unittest.skip('See https://github.com/tarantool/tarantool/issues/7700')
520+
@skip_or_run_datetime_2_11_test
520521
def test_tarantool_datetime_addition_winter_time_switch(self):
521522
case = self.datetime_addition_winter_time_switch_case
522523

0 commit comments

Comments
 (0)