Skip to content

Commit

Permalink
Added struct/binascii/base64 module
Browse files Browse the repository at this point in the history
The binascii module is implemented completely with:
   * Modifications for missing yield statement
   * Modifications to remove dependance on KeyError

The struct module misses pack_into and unpack_from
(dependency on buffer type)

The base64 modules misses encode and decode
(dependency on file operations)


git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@1069 7a2bd370-bda8-463c-979e-2900ccfb811e
  • Loading branch information
keesbos committed Aug 4, 2009
1 parent 9905688 commit c0692e4
Show file tree
Hide file tree
Showing 7 changed files with 1,582 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changes made to Pyjamas since 0.5p1
-----------------------------------

* Added base64 module (not encode/decode file)

* Added binascii module

* Added struct module (not pack_into/unpack_from)

* Added basic support for list comprehension (no ifs/multiple for)

* Added builtin import test, which will fail if the import code
Expand Down
49 changes: 49 additions & 0 deletions examples/libtest/Base64ModuleTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Testing time module

import sys
import UnitTest
import base64


class Base64ModuleTest(UnitTest.UnitTest):

def testBase64(self):
text = "Pyjamas is fun"

encodetext = base64.encodestring(text)
self.assertEqual(encodetext, 'UHlqYW1hcyBpcyBmdW4=\n')
decodetext = base64.decodestring(encodetext)
self.assertEqual(decodetext, text)

encodetext = base64.b64encode(text)
self.assertEqual(encodetext, 'UHlqYW1hcyBpcyBmdW4=')
decodetext = base64.b64decode(encodetext)
self.assertEqual(decodetext, text)

encodetext = base64.standard_b64encode(text)
self.assertEqual(encodetext, 'UHlqYW1hcyBpcyBmdW4=')
decodetext = base64.standard_b64decode(encodetext)
self.assertEqual(decodetext, text)

encodetext = base64.urlsafe_b64encode(text)
self.assertEqual(encodetext, 'UHlqYW1hcyBpcyBmdW4=')
decodetext = base64.urlsafe_b64decode(encodetext)
self.assertEqual(decodetext, text)

def testBase32(self):
text = "Pyjamas is fun"

encodetext = base64.b32encode(text)
self.assertEqual(encodetext, 'KB4WUYLNMFZSA2LTEBTHK3Q=')
decodetext = base64.b32decode(encodetext)
self.assertEqual(decodetext, text)

def testBase16(self):
text = "Pyjamas is fun"

encodetext = base64.b16encode(text)
self.assertEqual(encodetext, '50796A616D61732069732066756E')
decodetext = base64.b16decode(encodetext)
self.assertEqual(decodetext, text)


2 changes: 2 additions & 0 deletions examples/libtest/LibTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from TimeModuleTest import TimeModuleTest
from TypeCompatibilityTest import TypeCompatibilityTest
from UrllibModuleTest import UrllibModuleTest
from Base64ModuleTest import Base64ModuleTest

def main():
LoopTest().run()
Expand All @@ -57,6 +58,7 @@ def main():
TimeModuleTest().run()
TypeCompatibilityTest().run()
UrllibModuleTest().run()
Base64ModuleTest().run()

if __name__ == '__main__':
main()
Expand Down
Loading

0 comments on commit c0692e4

Please sign in to comment.