Skip to content

Commit f333e91

Browse files
committed
Skip snappy/gzip tests if they're not available
1 parent 2077653 commit f333e91

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/test_unit.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,16 @@ def test_submodule_namespace(self):
5555

5656

5757
class TestCodec(unittest.TestCase):
58+
59+
@unittest.skipUnless(has_gzip(), "Gzip not available")
5860
def test_gzip(self):
59-
if not has_gzip():
60-
return
6161
for i in xrange(ITERATIONS):
6262
s1 = random_string()
6363
s2 = gzip_decode(gzip_encode(s1))
6464
self.assertEquals(s1, s2)
6565

66+
@unittest.skipUnless(has_snappy(), "Snappy not available")
6667
def test_snappy(self):
67-
if not has_snappy():
68-
return
6968
for i in xrange(ITERATIONS):
7069
s1 = random_string()
7170
s2 = snappy_decode(snappy_encode(s1))
@@ -83,6 +82,7 @@ def test_create_message(self):
8382
self.assertEqual(msg.key, key)
8483
self.assertEqual(msg.value, payload)
8584

85+
@unittest.skipUnless(has_gzip(), "Snappy not available")
8686
def test_create_gzip(self):
8787
payloads = ["v1", "v2"]
8888
msg = create_gzip_message(payloads)
@@ -98,6 +98,7 @@ def test_create_gzip(self):
9898
"\xff\xff\x00\x00\x00\x02v2")
9999
self.assertEqual(decoded, expect)
100100

101+
@unittest.skipUnless(has_snappy(), "Snappy not available")
101102
def test_create_snappy(self):
102103
payloads = ["v1", "v2"]
103104
msg = create_snappy_message(payloads)
@@ -157,6 +158,7 @@ def test_decode_message_set(self):
157158
self.assertEqual(returned_offset2, 0)
158159
self.assertEqual(decoded_message2, create_message("v2"))
159160

161+
@unittest.skipUnless(has_gzip(), "Gzip not available")
160162
def test_decode_message_gzip(self):
161163
gzip_encoded = ('\xc0\x11\xb2\xf0\x00\x01\xff\xff\xff\xff\x00\x00\x000'
162164
'\x1f\x8b\x08\x00\xa1\xc1\xc5R\x02\xffc`\x80\x03\x01'
@@ -173,6 +175,7 @@ def test_decode_message_gzip(self):
173175
self.assertEqual(returned_offset2, 0)
174176
self.assertEqual(decoded_message2, create_message("v2"))
175177

178+
@unittest.skipUnless(has_snappy(), "Snappy not available")
176179
def test_decode_message_snappy(self):
177180
snappy_encoded = ('\xec\x80\xa1\x95\x00\x02\xff\xff\xff\xff\x00\x00'
178181
'\x00,8\x00\x00\x19\x01@\x10L\x9f[\xc2\x00\x00\xff'

0 commit comments

Comments
 (0)