[Scipy-svn] r4226 - in trunk/scipy/sandbox/exmplpackage: . benchmarks tests yyy yyy/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Mon May 5 06:49:41 EDT 2008


Author: matthew.brett at gmail.com
Date: 2008-05-05 05:49:32 -0500 (Mon, 05 May 2008)
New Revision: 4226

Added:
   trunk/scipy/sandbox/exmplpackage/benchmarks/
   trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py
Modified:
   trunk/scipy/sandbox/exmplpackage/__init__.py
   trunk/scipy/sandbox/exmplpackage/setup.py
   trunk/scipy/sandbox/exmplpackage/tests/test_foo.py
   trunk/scipy/sandbox/exmplpackage/yyy/__init__.py
   trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py
Log:
Updated exmplpackage to nose tests framework

Modified: trunk/scipy/sandbox/exmplpackage/__init__.py
===================================================================
--- trunk/scipy/sandbox/exmplpackage/__init__.py	2008-05-05 10:46:35 UTC (rev 4225)
+++ trunk/scipy/sandbox/exmplpackage/__init__.py	2008-05-05 10:49:32 UTC (rev 4226)
@@ -5,6 +5,10 @@
 # Get documentation string:
 from info_exmplpackage import __doc__
 
+# Import testing rig, allowing scipy.examplpackage.test()
+from scipy.testing.pkgtester import Tester
+test = Tester().test
+
 # Import symbols from sub-module:
 from foo import *
 

Added: trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py
===================================================================
--- trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py	2008-05-05 10:46:35 UTC (rev 4225)
+++ trunk/scipy/sandbox/exmplpackage/benchmarks/bench_foo.py	2008-05-05 10:49:32 UTC (rev 4226)
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+#
+__usage__ = """
+First ensure that scipy core modules are installed.
+
+Run benchmarks if scipy is installed:
+  python -c 'import scipy;scipy.exmplpackage.bench(label=<str>,verbose=<int>)'
+"""
+
+import sys
+from scipy.testing import *
+
+from scipy.sandbox.exmplpackage.foo import *
+
+class BenchFooBar(TestCase):
+
+    def bench_simple(self):
+        print 'A long timed benchmark here'
+

Modified: trunk/scipy/sandbox/exmplpackage/setup.py
===================================================================
--- trunk/scipy/sandbox/exmplpackage/setup.py	2008-05-05 10:46:35 UTC (rev 4225)
+++ trunk/scipy/sandbox/exmplpackage/setup.py	2008-05-05 10:49:32 UTC (rev 4226)
@@ -9,8 +9,9 @@
     from numpy.distutils.misc_util import Configuration
     config = Configuration('exmplpackage',parent_package,top_path)
 
-    # include test scripts from tests
+    # include test scripts from tests, and any benchmarks
     config.add_data_dir('tests')
+    config.add_data_dir('benchmarks')
 
     # exmplpackage contains Python sub-package yyy
     config.add_subpackage('yyy')

Modified: trunk/scipy/sandbox/exmplpackage/tests/test_foo.py
===================================================================
--- trunk/scipy/sandbox/exmplpackage/tests/test_foo.py	2008-05-05 10:46:35 UTC (rev 4225)
+++ trunk/scipy/sandbox/exmplpackage/tests/test_foo.py	2008-05-05 10:49:32 UTC (rev 4226)
@@ -9,10 +9,10 @@
 Build exmplpackage:
   python setup.py build
 Run tests locally:
-  python tests/test_foo.py [-l<int>] [-v<int>]
+  python tests/test_foo.py
 
 Run tests if scipy is installed:
-  python -c 'import scipy;scipy.exmplpackage.test(level=<int>,verbosity=<int>)'
+  python -c 'import scipy;scipy.exmplpackage.test(label=<str>,verbose=<int>)'
 """
 
 import sys
@@ -22,12 +22,12 @@
 
 class TestFooBar(TestCase):
 
-    def check_simple(self, level=1):
+    def test_simple(self):
         assert exmplpackage_foo_bar()=='Hello from exmplpackage_foo_bar'
 
 class TestFooGun(TestCase):
 
-    def check_simple(self, level=1):
+    def test_simple(self):
         assert foo_gun()=='Hello from foo_gun'
 
 if __name__ == "__main__":

Modified: trunk/scipy/sandbox/exmplpackage/yyy/__init__.py
===================================================================
--- trunk/scipy/sandbox/exmplpackage/yyy/__init__.py	2008-05-05 10:46:35 UTC (rev 4225)
+++ trunk/scipy/sandbox/exmplpackage/yyy/__init__.py	2008-05-05 10:49:32 UTC (rev 4226)
@@ -2,7 +2,11 @@
 yyy - Subpackage of Scipy module exmplpackage
 """
 
-__all__ = ['fun']
+__all__ = ['fun', 'test']
 
+# Import testing rig, allowing scipy.examplpackage.yyy.test()
+from scipy.testing.pkgtester import Tester
+test = Tester().test
+
 def fun():
     return 'Hello from yyy.fun'

Modified: trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py
===================================================================
--- trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py	2008-05-05 10:46:35 UTC (rev 4225)
+++ trunk/scipy/sandbox/exmplpackage/yyy/tests/test_yyy.py	2008-05-05 10:49:32 UTC (rev 4226)
@@ -1,16 +1,12 @@
 
-import sys
-from numpy.test.testing import *
+from scipy.testing import *
 
-set_package_path()
-# make sure that all yyy symbols are imported before the del statement:
 from yyy import fun
-del sys.path[0]
 
-class TestFun(NumpyTestCase):
-    def check_simple(self, level=1):
+class TestFun(TestCase):
+    def test_simple(self):
         assert fun()=='Hello from yyy.fun'
     #...
 
 if __name__ == "__main__":
-    NumpyTest().run()
+    nose.run(argv=['', __file__])




More information about the Scipy-svn mailing list