[gedit-latex] Add tests to compare relpath.py with os.path.relpath



commit 4d337e71cc86a0ff74828151b527c558d55b2a66
Author: John Stowers <john stowers gmail com>
Date:   Wed Jun 29 11:30:03 2011 +1200

    Add tests to compare relpath.py with os.path.relpath

 latex/relpath.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/latex/relpath.py b/latex/relpath.py
index 72fd0bd..19bd976 100644
--- a/latex/relpath.py
+++ b/latex/relpath.py
@@ -88,4 +88,17 @@ def relpath(base, comp):
 
     return os.path.join(*rel_path)
 
+if __name__ == "__main__":
+    import os.path
+
+    base = "file:///foo/bar/baz/bob"
+    bits = ("file:///foo","/bar","/baz","/bob","/cheese","/cake","/..","/..","/..","/foob")
+
+    path = ""
+    for b in bits:
+        path += b
+        print os.path.relpath(path, base),
+        try: print " V ", relpath(base, path)
+        except: print ""
+
 # ex:ts=4:et:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]