[Scipy-svn] r4097 - in trunk/scipy/io/arff/tests: . data

scipy-svn@scip... scipy-svn@scip...
Mon Apr 7 14:28:03 CDT 2008


Author: cdavid
Date: 2008-04-07 14:27:59 -0500 (Mon, 07 Apr 2008)
New Revision: 4097

Added:
   trunk/scipy/io/arff/tests/data/test3.arff
Modified:
   trunk/scipy/io/arff/tests/test_header.py
Log:
Change ValueError to ParseArffError exception in parse_type + test.

Added: trunk/scipy/io/arff/tests/data/test3.arff
===================================================================
--- trunk/scipy/io/arff/tests/data/test3.arff	2008-04-07 19:21:25 UTC (rev 4096)
+++ trunk/scipy/io/arff/tests/data/test3.arff	2008-04-07 19:27:59 UTC (rev 4097)
@@ -0,0 +1,6 @@
+@RELATION test3
+
+@ATTRIBUTE attr0	crap
+
+@DATA
+0.1, 0.2, 0.3, 0.4,class1

Modified: trunk/scipy/io/arff/tests/test_header.py
===================================================================
--- trunk/scipy/io/arff/tests/test_header.py	2008-04-07 19:21:25 UTC (rev 4096)
+++ trunk/scipy/io/arff/tests/test_header.py	2008-04-07 19:27:59 UTC (rev 4097)
@@ -4,12 +4,14 @@
 
 from scipy.testing import *
 
-from scipy.io.arff.arffread import read_header, MetaData, parse_type
+from scipy.io.arff.arffread import read_header, MetaData, parse_type, \
+                                   ParseArffError
 
 data_path = os.path.join(os.path.dirname(__file__), 'data')
 
 test1 = os.path.join(data_path, 'test1.arff')
 test2 = os.path.join(data_path, 'test2.arff')
+test3 = os.path.join(data_path, 'test3.arff')
 
 class HeaderTest(TestCase):
     def test_type_parsing(self):
@@ -23,6 +25,18 @@
         for i in range(len(attrs)):
             assert parse_type(attrs[i][1]) == expected[i]
 
+    def test_badtype_parsing(self):
+        """Test parsing wrong type of attribute from their value."""
+        ofile = open(test3)
+        rel, attrs = read_header(ofile)
+
+        for name, value in attrs:
+            try:
+                parse_type(value)
+                raise Error("Could parse type of crap, should not happen.")
+            except ParseArffError:
+                pass
+
     def test_fullheader1(self):
         """Parsing trivial header with nothing."""
         ofile = open(test1)



More information about the Scipy-svn mailing list