Skip to content

Commit

Permalink
Merge pull request #4 from brunovianarezende/master
Browse files Browse the repository at this point in the history
Fix error caused by missing StructError import
  • Loading branch information
klbostee committed Nov 13, 2012
2 parents d315a50 + 21b53da commit 2e1a806
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions ctypedbytes.py
Expand Up @@ -19,6 +19,7 @@ def classes():
import sys import sys
import typedbytes import typedbytes
from fastb import reads, writes from fastb import reads, writes
from struct import error as StructError




def flatten(iterable): def flatten(iterable):
Expand Down
16 changes: 15 additions & 1 deletion tests/testio.py
Expand Up @@ -3,7 +3,7 @@
import decimal import decimal
import datetime import datetime
import ctypedbytes as typedbytes import ctypedbytes as typedbytes

from struct import error as StructError


class TestIO(unittest.TestCase): class TestIO(unittest.TestCase):


Expand All @@ -25,6 +25,20 @@ def testio(self):
file.close() file.close()
os.remove("test.bin") os.remove("test.bin")


def testwrongio(self):
try:
file = open("test.bin", "wb")
output = typedbytes.Output(file)
output.writes([1])
file.close()
file = open("test.bin", "rb")
input = typedbytes.Input(file)
input = typedbytes.PairedInput(file)
self.assertRaises(StructError, lambda :list(input.reads()))
file.close()
finally:
os.remove("test.bin")

def testpairio(self): def testpairio(self):
objects = TestIO.objects objects = TestIO.objects
file = open("test.bin", "wb") file = open("test.bin", "wb")
Expand Down

0 comments on commit 2e1a806

Please sign in to comment.