Skip to content

Commit

Permalink
clean up exported global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
vsergeev committed Dec 9, 2013
1 parent c9e8352 commit cf36b35
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 80 deletions.
26 changes: 26 additions & 0 deletions test_umsgpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,22 @@
[ "32-bit raw", b"b" * 65536, b"\xdb\x00\x01\x00\x00" + b"b" * 65536 ],
]

# These are the only global variables that should be exported by umsgpack
exported_vars_test_vector = [
"Ext",
"PackException",
"UnpackException",
"UnsupportedTypeException",
"InsufficientDataException",
"InvalidStringException",
"ReservedCodeException",
"KeyNotPrimitiveException",
"KeyDuplicateException",
"packb",
"unpackb",
"compatibility",
]


################################################################################

Expand Down Expand Up @@ -304,6 +320,16 @@ def test_ext_exceptions(self):
except Exception as e:
self.assertTrue(isinstance(e, TypeError))

def test_namespacing(self):
# Get a list of global variables from umsgpack module
exported_vars = list(filter(lambda x: not x.startswith("_"), dir(umsgpack)))
# Ignore struct, collections, and sys imports
exported_vars = list(filter(lambda x: x != "struct" and x != "collections" and x != "sys", exported_vars))

self.assertTrue(len(exported_vars) == len(exported_vars_test_vector))
for var in exported_vars_test_vector:
self.assertTrue(var in exported_vars)

if __name__ == '__main__':
unittest.main()

Loading

0 comments on commit cf36b35

Please sign in to comment.