add test for tree_parse filesystem stuff
authorTero Marttila <terom@fixme.fi>
Mon, 16 Feb 2009 19:08:17 +0200
changeset 78 a46d2fc07951
parent 77 bef7196f7682
child 79 747554808944
add test for tree_parse filesystem stuff
tests/test_treeparse.py
--- a/tests/test_treeparse.py	Mon Feb 16 19:02:59 2009 +0200
+++ b/tests/test_treeparse.py	Mon Feb 16 19:08:17 2009 +0200
@@ -4,7 +4,7 @@
     Unit tests for qmsk.web.tree_parse
 """
 
-import unittest
+import unittest, os
 import tree_parse
 
 class TestTreeParse (unittest.TestCase) :
@@ -76,3 +76,26 @@
     
     # XXX: don't test root, as that's known-broken still
 
+class TestTreeParseFS (unittest.TestCase) :
+    DATA = ["foo", " bar", " quux"]
+    def setUp (self) :
+        """
+            Sets up a temporary file with the path in self.path, and self.DATA
+        """
+        
+        # XXX: supress warnings
+        self.path = os.tempnam()
+
+        # write out DATA
+        open(self.path, 'w').write('\n'.join(self.DATA))
+    
+    def tearDown (self) :
+        """
+            Removes the tempfile created earlier
+        """
+
+        os.remove(self.path)
+    
+    def test_simple (self) :
+        self.assertEquals(tree_parse.parse(self.path), (1, "foo", [(2, "bar", []), (3, "quux", [])]))
+