changeset 156:c5d3949639f5

tests: Now using string-versions for outputting.
author Sigurd Meldgaard <stm@daimi.au.dk>
date Fri, 04 Dec 2009 10:51:30 +0100
parents 58ef417d1f76
children cba610df903a
files pysmcl/test/unit/test_flow.py pysmcl/test/unit/test_secret_annotator.py pysmcl/test/unit/test_secret_ifs.py
diffstat 3 files changed, 8 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/test/unit/test_flow.py	Fri Dec 04 10:49:58 2009 +0100
+++ b/pysmcl/test/unit/test_flow.py	Fri Dec 04 10:51:30 2009 +0100
@@ -1,7 +1,4 @@
-
-
 import unittest
-import StringIO
 
 from pysmcl.ast_wrapper import *
 from pysmcl.range_analysis import RangeAnalysis, Bottom
@@ -24,8 +21,7 @@
         flow = Flow()
         flow.flow(prog.body[0])
         entry = flow.to_dot(prog.body[0])
-        output = StringIO.StringIO()
-        Graph(entry).to_dot(output)
+        result = Graph(entry).to_dot_string()
         expected_result = \
 """digraph G {
   in -> 1
@@ -42,7 +38,7 @@
     4 [label="z = (a + 2) - a"]
 }
 """
-        self.assertEquals(output.getvalue(), expected_result)
+        self.assertEquals(result, expected_result)
 
     def test_while(self):
         p = 7
@@ -59,8 +55,7 @@
         flow = Flow()
         flow.flow(prog.body[0])
         entry = flow.to_dot(prog.body[0])
-        output = StringIO.StringIO()
-        Graph(entry).to_dot(output)
+        result = Graph(entry).to_dot_string()
         expected_result = \
 """digraph G {
   in -> 6
@@ -82,7 +77,7 @@
     9 [label="y"]
 }
 """
-        self.assertEquals(output.getvalue(), expected_result)
+        self.assertEquals(result, expected_result)
 
 
 if __name__ == '__main__':
--- a/pysmcl/test/unit/test_secret_annotator.py	Fri Dec 04 10:49:58 2009 +0100
+++ b/pysmcl/test/unit/test_secret_annotator.py	Fri Dec 04 10:51:30 2009 +0100
@@ -1,5 +1,3 @@
-
-
 import unittest
 
 from pysmcl.ast_wrapper import *
--- a/pysmcl/test/unit/test_secret_ifs.py	Fri Dec 04 10:49:58 2009 +0100
+++ b/pysmcl/test/unit/test_secret_ifs.py	Fri Dec 04 10:51:30 2009 +0100
@@ -1,14 +1,13 @@
 import unittest
-import StringIO
 from pysmcl.ast_wrapper import parse
-from pysmcl.pretty_print import pprint
+from pysmcl.pretty_print import pprint_string
 from pysmcl.secret_ifs import TransformIfs
 from pysmcl.secret_annotator import secret_analysis
 
 
 class SecretIfTest(unittest.TestCase):
 
-    def test_ifs(self):
+    def test_if(self):
         expected_result = \
 """def f(x):
     cond0 = x
@@ -26,9 +25,8 @@
         trans = TransformIfs()
         secret_analysis(prog.body[0])
         prog = trans.visit(prog)
-        output = StringIO.StringIO()
-        pprint(prog, output)
-        self.assertEquals(expected_result, output.getvalue())
+        result = pprint_string(prog)
+        self.assertEquals(expected_result, result)
 
 if __name__ == '__main__':
     unittest.main()