diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2011-07-18 22:26:14 -0700 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2011-07-18 22:26:14 -0700 |
commit | 5d6f855387e61ae21371734fdd7a48bca301fe64 (patch) | |
tree | c9af147d8dd9c07c3ca6014db0b5036c5fbf14d7 /test/test_encoding.py | |
parent | b0849387b74c9e289bd2ed4f0dc6bd1b7829c10f (diff) | |
parent | 25b063119045084bd3fd10a2382b4bc2f67ff2bf (diff) | |
download | mitmproxy-5d6f855387e61ae21371734fdd7a48bca301fe64.tar.gz mitmproxy-5d6f855387e61ae21371734fdd7a48bca301fe64.tar.bz2 mitmproxy-5d6f855387e61ae21371734fdd7a48bca301fe64.zip |
Merge pull request #9 from alts/toggle_encodings
Toggle encodings
Diffstat (limited to 'test/test_encoding.py')
-rw-r--r-- | test/test_encoding.py | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/test/test_encoding.py b/test/test_encoding.py index 00632c0e..dff146ee 100644 --- a/test/test_encoding.py +++ b/test/test_encoding.py @@ -4,30 +4,28 @@ import libpry import cStringIO import gzip, zlib -class udecode_identity(libpry.AutoTree): - def test_decode(self): - assert 'string' == encoding.decode('identity', 'string') +class uidentity(libpry.AutoTree): + def test_simple(self): + assert "string" == encoding.decode("identity", "string") + assert "string" == encoding.encode("identity", "string") def test_fallthrough(self): - assert 'string' == encoding.decode('nonexistent encoding', 'string') + assert "string" == encoding.decode("nonexistent encoding", "string") + assert "string" == encoding.encode("nonexistent encoding", "string") -class udecode_gzip(libpry.AutoTree): +class ugzip(libpry.AutoTree): def test_simple(self): - s = cStringIO.StringIO() - gf = gzip.GzipFile(fileobj=s, mode='wb') - gf.write('string') - gf.close() - assert 'string' == encoding.decode('gzip', s.getvalue()) + assert "string" == encoding.decode("gzip", encoding.encode("gzip", "string")) assert None == encoding.decode("gzip", "bogus") -class udecode_deflate(libpry.AutoTree): +class udeflate(libpry.AutoTree): def test_simple(self): - assert 'string' == encoding.decode('deflate', zlib.compress('string')) - assert 'string' == encoding.decode('deflate', zlib.compress('string')[2:-4]) + assert "string" == encoding.decode("deflate", encoding.encode("deflate", "string")) + assert "string" == encoding.decode("deflate", encoding.encode("deflate", "string")[2:-4]) assert None == encoding.decode("deflate", "bogus") tests = [ - udecode_identity(), - udecode_gzip(), - udecode_deflate() + uidentity(), + ugzip(), + udeflate() ] |