[py-svn] r10506 - in py/branch/py-collect/path: . testing

hpk at codespeak.net hpk at codespeak.net
Sun Apr 10 13:50:04 CEST 2005


Author: hpk
Date: Sun Apr 10 13:50:04 2005
New Revision: 10506

Modified:
   py/branch/py-collect/path/common.py
   py/branch/py-collect/path/testing/fscommon.py
Log:
make relto() a bit more picky about the type of argument 
it takes. 



Modified: py/branch/py-collect/path/common.py
==============================================================================
--- py/branch/py-collect/path/common.py	(original)
+++ py/branch/py-collect/path/common.py	Sun Apr 10 13:50:04 2005
@@ -116,6 +116,8 @@
         """ return a string which is the relative part of the path
         to the given 'relpath'. 
         """
+        if not isinstance(relpath, (str, PathBase)): 
+            raise TypeError("%r: not a string or path object" %(relpath,))
         strrelpath = str(relpath) 
         if strrelpath and strrelpath[-1] != self.sep: 
             strrelpath += self.sep 

Modified: py/branch/py-collect/path/testing/fscommon.py
==============================================================================
--- py/branch/py-collect/path/testing/fscommon.py	(original)
+++ py/branch/py-collect/path/testing/fscommon.py	Sun Apr 10 13:50:04 2005
@@ -118,6 +118,9 @@
         url = self.root.join("samplefile")
         assert url.mtime() > 0
 
+    def test_relto_wrong_type(self): 
+        py.test.raises(TypeError, "self.root.relto(42)")
+
     def test_visit_filesonly(self):
         l = []
         for i in self.root.visit(checker(file=1)):



More information about the pytest-commit mailing list