]> rtime.felk.cvut.cz Git - wvtest.git/commitdiff
python: oops, fix handling for tests in current directory instead of t/
authorAvery Pennarun <apenwarr@gmail.com>
Tue, 14 Aug 2012 07:23:49 +0000 (03:23 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 14 Aug 2012 07:26:23 +0000 (03:26 -0400)
And add a test for that case so we don't break it in the future.

python/Makefile
python/basedir_test.py [new file with mode: 0644]
python/wvtest.py

index 6d54894ba6e0aeb7072712f327aefbbb4eb682fe..5a2d068597a4513483836d172c0d8e7bafd1e144 100644 (file)
@@ -5,8 +5,10 @@ all:
 
 runtests:
        ./wvtest.py \
-               $(patsubst ./%t,%t/*.py,$(shell find -type d -name t))
+               $(patsubst ./%t,%t/*.py,$(shell find -type d -name t)) \
+               basedir_test.py
        python t/twvtest.py
+       python basedir_test.py
 
 test:
        ../wvtestrun $(MAKE) runtests
diff --git a/python/basedir_test.py b/python/basedir_test.py
new file mode 100644 (file)
index 0000000..932f9d2
--- /dev/null
@@ -0,0 +1,12 @@
+from wvtest import *
+
+
+@wvtest
+def basedirtest():
+    # check that wvtest works with test files in the base directory, not
+    # just in subdirs.
+    WVPASS()
+
+
+if __name__ == '__main__':
+    wvtest_main()
index 833cfc403c6fddef36a3ff8dca2f7a94f2f9551c..dc047402837ec4a38743c86c9ca6646079ecaa9e 100755 (executable)
@@ -137,7 +137,7 @@ def _run_in_chdir(path, func, *args, **kwargs):
     oldwd = os.getcwd()
     oldpath = sys.path
     try:
-        os.chdir(path)
+        if path: os.chdir(path)
         sys.path += [path, os.path.split(path)[0]]
         return func(*args, **kwargs)
     finally:
@@ -146,6 +146,7 @@ def _run_in_chdir(path, func, *args, **kwargs):
 
 
 def _runtest(fname, f):
+    import wvtest as _wvtestmod
     mod = inspect.getmodule(f)
     relpath = os.path.relpath(mod.__file__, os.getcwd()).replace('.pyc', '.py')
     print
@@ -157,7 +158,7 @@ def _runtest(fname, f):
         print
         print traceback.format_exc()
         tb = sys.exc_info()[2]
-        wvtest._result(e, traceback.extract_tb(tb)[1], 'EXCEPTION')
+        _wvtestmod._result(e, traceback.extract_tb(tb)[1], 'EXCEPTION')
 
 
 def _run_registered_tests():