@@ -71,42 +71,58 @@ def test_interval_positional_init(self):
71
71
'python' : tarantool .Interval (year = 1 ),
72
72
'msgpack' : (b'\x02 \x00 \x01 \x08 \x01 ' ),
73
73
'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)' ,
74
76
},
75
77
'big_year' : {
76
78
'python' : tarantool .Interval (year = 1000 ),
77
79
'msgpack' : (b'\x02 \x00 \xcd \x03 \xe8 \x08 \x01 ' ),
78
80
'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)' ,
79
83
},
80
84
'date' : {
81
85
'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 ),
82
86
'msgpack' : (b'\x04 \x00 \x01 \x01 \x02 \x03 \x03 \x08 \x01 ' ),
83
87
'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)' ,
84
90
},
85
91
'big_month_date' : {
86
92
'python' : tarantool .Interval (year = 1 , month = 100000 , day = 3 ),
87
93
'msgpack' : (b'\x04 \x00 \x01 \x01 \xce \x00 \x01 \x86 \xa0 \x03 \x03 \x08 \x01 ' ),
88
94
'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)' ,
89
97
},
90
98
'time' : {
91
99
'python' : tarantool .Interval (hour = 1 , minute = 2 , sec = 3 ),
92
100
'msgpack' : (b'\x04 \x04 \x01 \x05 \x02 \x06 \x03 \x08 \x01 ' ),
93
101
'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)' ,
94
104
},
95
105
'big_seconds_time' : {
96
106
'python' : tarantool .Interval (hour = 1 , minute = 2 , sec = 3000 ),
97
107
'msgpack' : (b'\x04 \x04 \x01 \x05 \x02 \x06 \xcd \x0b \xb8 \x08 \x01 ' ),
98
108
'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)' ,
99
111
},
100
112
'datetime' : {
101
113
'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 , sec = 3000 ),
102
114
'msgpack' : (b'\x07 \x00 \x01 \x01 \x02 \x03 \x03 \x04 \x01 \x05 \x02 \x06 \xcd \x0b \xb8 \x08 \x01 ' ),
103
115
'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
104
116
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)' ,
105
119
},
106
120
'nanoseconds' : {
107
121
'python' : tarantool .Interval (nsec = 10000000 ),
108
122
'msgpack' : (b'\x02 \x07 \xce \x00 \x98 \x96 \x80 \x08 \x01 ' ),
109
123
'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)' ,
110
126
},
111
127
'datetime_with_nanoseconds' : {
112
128
'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 ,
@@ -115,6 +131,8 @@ def test_interval_positional_init(self):
115
131
b'\x00 \x98 \x96 \x80 \x08 \x01 ' ),
116
132
'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
117
133
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)' ,
118
136
},
119
137
'datetime_none_adjust' : {
120
138
'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 ,
@@ -124,6 +142,8 @@ def test_interval_positional_init(self):
124
142
b'\x00 \x98 \x96 \x80 \x08 \x01 ' ),
125
143
'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
126
144
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)' ,
127
147
},
128
148
'datetime_excess_adjust' : {
129
149
'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 ,
@@ -133,6 +153,8 @@ def test_interval_positional_init(self):
133
153
b'\x00 \x98 \x96 \x80 ' ),
134
154
'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
135
155
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)' ,
136
158
},
137
159
'datetime_last_adjust' : {
138
160
'python' : tarantool .Interval (year = 1 , month = 2 , day = 3 , hour = 1 , minute = 2 ,
@@ -142,21 +164,29 @@ def test_interval_positional_init(self):
142
164
b'\x00 \x98 \x96 \x80 \x08 \x02 ' ),
143
165
'tarantool' : r"datetime.interval.new({year=1, month=2, day=3, hour=1, "
144
166
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)' ,
145
169
},
146
170
'all_zeroes' : {
147
171
'python' : tarantool .Interval (adjust = tarantool .IntervalAdjust .EXCESS ),
148
172
'msgpack' : (b'\x00 ' ),
149
173
'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)' ,
150
176
},
151
177
'weeks' : {
152
178
'python' : tarantool .Interval (week = 3 ),
153
179
'msgpack' : (b'\x02 \x02 \x03 \x08 \x01 ' ),
154
180
'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)' ,
155
183
},
156
184
'date_with_week' : {
157
185
'python' : tarantool .Interval (year = 1 , month = 2 , week = 3 , day = 4 ),
158
186
'msgpack' : (b'\x05 \x00 \x01 \x01 \x02 \x02 \x03 \x03 \x04 \x08 \x01 ' ),
159
187
'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)' ,
160
190
},
161
191
'datetime_with_week' : {
162
192
'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):
165
195
b'\x07 \xce \x00 \x98 \x96 \x80 \x08 \x01 ' ),
166
196
'tarantool' : r"datetime.interval.new({year=1, month=2, week=3, day=4, hour=1, "
167
197
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)' ,
168
200
},
169
201
}
170
202
@@ -216,6 +248,12 @@ def test_tarantool_encode(self):
216
248
217
249
self .assertSequenceEqual (self .adm (lua_eval ), [True ])
218
250
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
+
219
257
def test_unknown_field_decode (self ):
220
258
case = b'\x01 \x09 \xce \x00 \x98 \x96 \x80 '
221
259
self .assertRaisesRegex (
0 commit comments