From: Avery Pennarun Date: Tue, 14 Aug 2012 07:23:49 +0000 (-0400) Subject: python: oops, fix handling for tests in current directory instead of t/ X-Git-Url: https://rtime.felk.cvut.cz/gitweb/wvtest.git/commitdiff_plain/9d057f923fe2be96c09d165af88a78c460d3fbf9 python: oops, fix handling for tests in current directory instead of t/ And add a test for that case so we don't break it in the future. --- diff --git a/python/Makefile b/python/Makefile index 6d54894..5a2d068 100644 --- a/python/Makefile +++ b/python/Makefile @@ -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 index 0000000..932f9d2 --- /dev/null +++ b/python/basedir_test.py @@ -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() diff --git a/python/wvtest.py b/python/wvtest.py index 833cfc4..dc04740 100755 --- a/python/wvtest.py +++ b/python/wvtest.py @@ -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():