@@ -71,42 +71,58 @@ def test_interval_positional_init(self):
7171 'python' : tarantool .Interval (year = 1 ),
7272 'msgpack' : (b'\x02 \x00 \x01 \x08 \x01 ' ),
7373 'tarantool' : r"datetime.interval.new({year=1})" ,
74+ 'str' : 'tarantool.Interval(year=1, month=0, week=0, day=0, hour=0, '
75+ 'minute=0, sec=0, nsec=0, adjust=Adjust.NONE)' ,
7476 },
7577 'big_year' : {
7678 'python' : tarantool .Interval (year = 1000 ),
7779 'msgpack' : (b'\x02 \x00 \xcd \x03 \xe8 \x08 \x01 ' ),
7880 'tarantool' : r"datetime.interval.new({year=1000})" ,
81+ 'str' : 'tarantool.Interval(year=1000, month=0, week=0, day=0, hour=0, '
82+ 'minute=0, sec=0, nsec=0, adjust=Adjust.NONE)' ,
7983 },
8084 'date' : {
8185 'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 ),
8286 'msgpack' : (b'\x04 \x00 \x01 \x01 \x02 \x03 \x03 \x08 \x01 ' ),
8387 'tarantool' : r"datetime.interval.new({year=1, month=2, day=3})" ,
88+ 'str' : 'tarantool.Interval(year=1, month=2, week=0, day=3, hour=0, '
89+ 'minute=0, sec=0, nsec=0, adjust=Adjust.NONE)' ,
8490 },
8591 'big_month_date' : {
8692 'python' : tarantool .Interval (year = 1 , month = 100000 , day = 3 ),
8793 'msgpack' : (b'\x04 \x00 \x01 \x01 \xce \x00 \x01 \x86 \xa0 \x03 \x03 \x08 \x01 ' ),
8894 'tarantool' : r"datetime.interval.new({year=1, month=100000, day=3})" ,
95+ 'str' : 'tarantool.Interval(year=1, month=100000, week=0, day=3, hour=0, '
96+ 'minute=0, sec=0, nsec=0, adjust=Adjust.NONE)' ,
8997 },
9098 'time' : {
9199 'python' : tarantool .Interval (hour = 1 , minute = 2 , sec = 3 ),
92100 'msgpack' : (b'\x04 \x04 \x01 \x05 \x02 \x06 \x03 \x08 \x01 ' ),
93101 'tarantool' : r"datetime.interval.new({hour=1, min=2, sec=3})" ,
102+ 'str' : 'tarantool.Interval(year=0, month=0, week=0, day=0, hour=1, '
103+ 'minute=2, sec=3, nsec=0, adjust=Adjust.NONE)' ,
94104 },
95105 'big_seconds_time' : {
96106 'python' : tarantool .Interval (hour = 1 , minute = 2 , sec = 3000 ),
97107 'msgpack' : (b'\x04 \x04 \x01 \x05 \x02 \x06 \xcd \x0b \xb8 \x08 \x01 ' ),
98108 'tarantool' : r"datetime.interval.new({hour=1, min=2, sec=3000})" ,
109+ 'str' : 'tarantool.Interval(year=0, month=0, week=0, day=0, hour=1, '
110+ 'minute=2, sec=3000, nsec=0, adjust=Adjust.NONE)' ,
99111 },
100112 'datetime' : {
101113 'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 , sec = 3000 ),
102114 'msgpack' : (b'\x07 \x00 \x01 \x01 \x02 \x03 \x03 \x04 \x01 \x05 \x02 \x06 \xcd \x0b \xb8 \x08 \x01 ' ),
103115 'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
104116 r"min=2, sec=3000})" ,
117+ 'str' : 'tarantool.Interval(year=1, month=2, week=0, day=3, hour=1, '
118+ 'minute=2, sec=3000, nsec=0, adjust=Adjust.NONE)' ,
105119 },
106120 'nanoseconds' : {
107121 'python' : tarantool .Interval (nsec = 10000000 ),
108122 'msgpack' : (b'\x02 \x07 \xce \x00 \x98 \x96 \x80 \x08 \x01 ' ),
109123 'tarantool' : r"datetime.interval.new({nsec=10000000})" ,
124+ 'str' : 'tarantool.Interval(year=0, month=0, week=0, day=0, hour=0, '
125+ 'minute=0, sec=0, nsec=10000000, adjust=Adjust.NONE)' ,
110126 },
111127 'datetime_with_nanoseconds' : {
112128 'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 ,
@@ -115,6 +131,8 @@ def test_interval_positional_init(self):
115131 b'\x00 \x98 \x96 \x80 \x08 \x01 ' ),
116132 'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
117133 r"min=2, sec=3000, nsec=10000000})" ,
134+ 'str' : 'tarantool.Interval(year=1, month=2, week=0, day=3, hour=1, '
135+ 'minute=2, sec=3000, nsec=10000000, adjust=Adjust.NONE)' ,
118136 },
119137 'datetime_none_adjust' : {
120138 'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 ,
@@ -124,6 +142,8 @@ def test_interval_positional_init(self):
124142 b'\x00 \x98 \x96 \x80 \x08 \x01 ' ),
125143 'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
126144 r"min=2, sec=3000, nsec=10000000, adjust='none'})" ,
145+ 'str' : 'tarantool.Interval(year=1, month=2, week=0, day=3, hour=1, '
146+ 'minute=2, sec=3000, nsec=10000000, adjust=Adjust.NONE)' ,
127147 },
128148 'datetime_excess_adjust' : {
129149 'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 ,
@@ -133,6 +153,8 @@ def test_interval_positional_init(self):
133153 b'\x00 \x98 \x96 \x80 ' ),
134154 'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
135155 r"min=2, sec=3000, nsec=10000000, adjust='excess'})" ,
156+ 'str' : 'tarantool.Interval(year=1, month=2, week=0, day=3, hour=1, '
157+ 'minute=2, sec=3000, nsec=10000000, adjust=Adjust.EXCESS)' ,
136158 },
137159 'datetime_last_adjust' : {
138160 'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 ,
@@ -142,21 +164,29 @@ def test_interval_positional_init(self):
142164 b'\x00 \x98 \x96 \x80 \x08 \x02 ' ),
143165 'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
144166 r"min=2, sec=3000, nsec=10000000, adjust='last'})" ,
167+ 'str' : 'tarantool.Interval(year=1, month=2, week=0, day=3, hour=1, '
168+ 'minute=2, sec=3000, nsec=10000000, adjust=Adjust.LAST)' ,
145169 },
146170 'all_zeroes' : {
147171 'python' : tarantool .Interval (adjust = tarantool .IntervalAdjust .EXCESS ),
148172 'msgpack' : (b'\x00 ' ),
149173 'tarantool' : r"datetime.interval.new({adjust='excess'})" ,
174+ 'str' : 'tarantool.Interval(year=0, month=0, week=0, day=0, hour=0, '
175+ 'minute=0, sec=0, nsec=0, adjust=Adjust.EXCESS)' ,
150176 },
151177 'weeks' : {
152178 'python' : tarantool .Interval (week = 3 ),
153179 'msgpack' : (b'\x02 \x02 \x03 \x08 \x01 ' ),
154180 'tarantool' : r"datetime.interval.new({week=3})" ,
181+ 'str' : 'tarantool.Interval(year=0, month=0, week=3, day=0, hour=0, '
182+ 'minute=0, sec=0, nsec=0, adjust=Adjust.NONE)' ,
155183 },
156184 'date_with_week' : {
157185 'python' : tarantool .Interval (year = 1 , month = 2 , week = 3 , day = 4 ),
158186 'msgpack' : (b'\x05 \x00 \x01 \x01 \x02 \x02 \x03 \x03 \x04 \x08 \x01 ' ),
159187 'tarantool' : r"datetime.interval.new({year=1, month=2, week=3, day=4})" ,
188+ 'str' : 'tarantool.Interval(year=1, month=2, week=3, day=4, hour=0, '
189+ 'minute=0, sec=0, nsec=0, adjust=Adjust.NONE)' ,
160190 },
161191 'datetime_with_week' : {
162192 'python' : tarantool .Interval (year = 1 , month = 2 , week = 3 , day = 4 , hour = 1 , minute = 2 ,
@@ -165,6 +195,8 @@ def test_interval_positional_init(self):
165195 b'\x07 \xce \x00 \x98 \x96 \x80 \x08 \x01 ' ),
166196 'tarantool' : r"datetime.interval.new({year=1, month=2, week=3, day=4, hour=1, "
167197 r"min=2, sec=3000, nsec=10000000})" ,
198+ 'str' : 'tarantool.Interval(year=1, month=2, week=3, day=4, hour=1, '
199+ 'minute=2, sec=3000, nsec=10000000, adjust=Adjust.NONE)' ,
168200 },
169201 }
170202
@@ -216,6 +248,12 @@ def test_tarantool_encode(self):
216248
217249 self .assertSequenceEqual (self .adm (lua_eval ), [True ])
218250
251+ def test_class_string (self ):
252+ for name , case in self .cases .items ():
253+ with self .subTest (msg = name ):
254+ self .assertEqual (str (case ['python' ]), case ['str' ])
255+ self .assertEqual (repr (case ['python' ]), case ['str' ])
256+
219257 def test_unknown_field_decode (self ):
220258 case = b'\x01 \x09 \xce \x00 \x98 \x96 \x80 '
221259 self .assertRaisesRegex (
0 commit comments