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

[minion-cvs] Tests for improved error messages



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv15556/lib/mixminion

Modified Files:
	test.py 
Log Message:
Tests for improved error messages

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- test.py	31 Aug 2003 19:29:29 -0000	1.150
+++ test.py	3 Sep 2003 15:54:18 -0000	1.151
@@ -684,6 +684,26 @@
         q.clear()
         self.assert_(q.empty())
         self.assertRaises(Queue.Empty, q.get_nowait)
+
+    def test_englishSequence(self):
+        es = englishSequence
+        self.assertEquals("none", es([]))
+        self.assertEquals("fred", es(["fred"]))
+        self.assertEquals("fred and joe", es(["fred", "joe"]))
+        self.assertEquals("fred, joe, and bob", es(["fred", "joe", "bob"]))
+        self.assertEquals("fred, jr; joe; and bob", 
+                          es(["fred, jr", "joe", "bob"]))
+        self.assertEquals("fred, jr; and bob",
+                          es(["fred, jr", "bob"]))
+        self.assertEquals("Kernighan and Ritchie; and Laurel and Hardy",
+                          es(["Kernighan and Ritchie", "Laurel and Hardy"]))
+        self.assertEquals("Kernighan and Ritchie; or Laurel and Hardy",
+                          es(["Kernighan and Ritchie", "Laurel and Hardy"],
+                             compound="or"))
+        self.assertEquals("fred", es(["fred"], compound="or"))
+        self.assertEquals("fred or joe", es(["fred", "joe"], compound="or"))
+        self.assertEquals("fred, joe, or bob", 
+                          es(["fred", "joe", "bob"], compound="or"))
         
 #----------------------------------------------------------------------
 
@@ -2876,7 +2896,7 @@
         self.assertEquals(queue._metadata_cache, { h1 : [2,3], h3: h3 })
         self.assert_(os.path.exists(os.path.join(d_d, "rmvm_"+h2)))
         self.assert_(os.path.exists(os.path.join(d_d, "rmv_"+h2)))
-        queue.cleanQueue()
+        queue.cleanQueue(self.unlink)
         self.assert_(not os.path.exists(os.path.join(d_d, "rmvm_"+h2)))
         self.assert_(not os.path.exists(os.path.join(d_d, "rmv_"+h2)))
 
@@ -3834,7 +3854,8 @@
                           'IntAM': ('ALLOW*', _parseInt, None),
                           'IntAMD': ('ALLOW*', _parseInt, ["5", "2"]),
                           'IntAMD2': ('ALLOW*', _parseInt, ["5", "2"]),
-                          'IntRS': ('REQUIRE', _parseInt, None) }
+                          'IntRS': ('REQUIRE', _parseInt, None),
+                          'Quz' : ('ALLOW', None, None) }
                 }
     def __init__(self, fname=None, string=None, restrict=0):
         self._restrictFormat = restrict
@@ -3945,6 +3966,24 @@
         fails("[Sec2]\nBap = 9\nQuz=6\n") # Missing section
         fails("[Sec1]\nFoo 1\n[Sec2]\nBap = 9\n") # Missing require*
         fails("[Sec1]\nFoo: Bar\n[Sec3]\nIntRS=Z\n") # Failed validation
+
+        try:
+            TestConfigFile(None,"[Sec1]\nFoo: 1\nBap:1\n")
+        except ConfigError, e:
+            self.assertEndsWith(str(e), 
+                                "Unrecognized key Bap on line 3. This "
+                                "key belongs in Sec2, but appears in Sec1.")
+        try:
+            TestConfigFile(None,"[Sec1]\nFoo: 1\nQuz:1\n")
+        except ConfigError, e:
+            self.assertEndsWith(str(e), 
+                               "Unrecognized key Quz on line 3. This key "
+                               "belongs in Sec2 or Sec3, but appears in Sec1.")
+
+        try:
+            TestConfigFile(None,"[Sec1]\nFoo: 1\nBan:1\n")
+        except ConfigError, e:
+            self.assertEndsWith(str(e), "Unrecognized key Ban on line 3")
 
         # now test the restricted format
         def failsR(string, self=self):