1
- import os
2
- import random
1
+ # -*- coding: utf-8 -*-
3
2
import struct
4
3
import unittest2
5
4
import kafka .util
6
5
import kafka .common
7
6
7
+
8
8
class UtilTest (unittest2 .TestCase ):
9
9
@unittest2 .skip ("Unwritten" )
10
10
def test_relative_unpack (self ):
@@ -64,21 +64,20 @@ def test_read_short_string(self):
64
64
self .assertEqual (kafka .util .read_short_string ('\x00 \x00 ' , 0 ), ('' , 2 ))
65
65
self .assertEqual (kafka .util .read_short_string ('\x00 \x0b some string' , 0 ), ('some string' , 13 ))
66
66
67
- def test_read_int_string__insufficient_data (self ):
67
+ def test_read_int_string__insufficient_data2 (self ):
68
68
with self .assertRaises (kafka .common .BufferUnderflowError ):
69
69
kafka .util .read_int_string ('\x00 \x02 1' , 0 )
70
70
71
- def test_relative_unpack (self ):
71
+ def test_relative_unpack2 (self ):
72
72
self .assertEqual (
73
73
kafka .util .relative_unpack ('>hh' , '\x00 \x01 \x00 \x00 \x02 ' , 0 ),
74
74
((1 , 0 ), 4 )
75
75
)
76
76
77
- def test_relative_unpack (self ):
77
+ def test_relative_unpack3 (self ):
78
78
with self .assertRaises (kafka .common .BufferUnderflowError ):
79
79
kafka .util .relative_unpack ('>hh' , '\x00 ' , 0 )
80
80
81
-
82
81
def test_group_by_topic_and_partition (self ):
83
82
t = kafka .common .TopicAndPartition
84
83
@@ -91,12 +90,12 @@ def test_group_by_topic_and_partition(self):
91
90
]
92
91
93
92
self .assertEqual (kafka .util .group_by_topic_and_partition (l ), {
94
- "a" : {
95
- 1 : t ("a" , 1 ),
96
- 2 : t ("a" , 2 ),
97
- 3 : t ("a" , 3 ),
93
+ "a" : {
94
+ 1 : t ("a" , 1 ),
95
+ 2 : t ("a" , 2 ),
96
+ 3 : t ("a" , 3 ),
98
97
},
99
- "b" : {
100
- 3 : t ("b" , 3 ),
98
+ "b" : {
99
+ 3 : t ("b" , 3 ),
101
100
}
102
101
})
0 commit comments