Permalink
Browse files

Added another test and also now do type checking on construction. Fixes

  • Loading branch information...
jaraco committed Nov 14, 2012
1 parent acc5f3b commit 4ca082c5aa235b05ab563ec03349c729e1b45e37
Showing with 16 additions and 0 deletions.
  1. +5 −0 path.py
  2. +11 −0 test_path.py
View
@@ -92,6 +92,11 @@ class path(unicode):
counterparts in os.path.
"""
+ def __init__(self, other):
+ super(path, self).__init__(self, other)
+ if not isinstance(other, basestring):
+ raise TypeError("path must be a string")
+
module = os.path
"The path module to use for path operations."
View
@@ -82,6 +82,17 @@ def testConstructionFromNone(self):
else:
raise Exception("DID NOT RAISE")
+ def testConstructionFromInt(self):
+ """
+ path class should raise a TypeError when constructed from an integer.
+ """
+ try:
+ path(1)
+ except TypeError:
+ pass
+ else:
+ raise Exception("DID NOT RAISE")
+
def testStringCompatibility(self):
""" Test compatibility with ordinary strings. """
x = path('xyzzy')

0 comments on commit 4ca082c

Please sign in to comment.