[Numpy-svn] r6340 - trunk/numpy/lib/tests

numpy-svn@scip... numpy-svn@scip...
Wed Feb 4 15:53:46 CST 2009


Author: pierregm
Date: 2009-02-04 15:53:05 -0600 (Wed, 04 Feb 2009)
New Revision: 6340

Modified:
   trunk/numpy/lib/tests/test__iotools.py
Log:
test_upgrademapper : got rid of the dateutil import

Modified: trunk/numpy/lib/tests/test__iotools.py
===================================================================
--- trunk/numpy/lib/tests/test__iotools.py	2009-02-04 20:52:36 UTC (rev 6339)
+++ trunk/numpy/lib/tests/test__iotools.py	2009-02-04 21:53:05 UTC (rev 6340)
@@ -130,14 +130,15 @@
     #
     def test_upgrademapper(self):
         "Tests updatemapper"
-        try:
-            import dateutil.parser
-            import datetime
-            dateparser = dateutil.parser.parse
-            StringConverter.upgrade_mapper(dateparser, datetime.date(2000,1,1))
-            convert = StringConverter(dateparser, datetime.date(2000, 1, 1))
-            test = convert('2001-01-01')
-            assert_equal(test, datetime.datetime(2001, 01, 01, 00, 00, 00))
-        except ImportError:
-            pass
+        from datetime import date
+        import time
+        dateparser = lambda s : date(*time.strptime(s, "%Y-%m-%d")[:3])
+        StringConverter.upgrade_mapper(dateparser, date(2000,1,1))
+        convert = StringConverter(dateparser, date(2000, 1, 1))
+        test = convert('2001-01-01')
+        assert_equal(test, date(2001, 01, 01))
+        test = convert('2009-01-01')
+        assert_equal(test, date(2009, 01, 01))
+        test = convert('')
+        assert_equal(test, date(2000, 01, 01))
 



More information about the Numpy-svn mailing list