From fe3b3f07b04313b539ea8894dca05ba6e6eb60aa Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 11 Sep 2016 22:20:28 +0300 Subject: [PATCH] Use pytest for testing --- project_template/tests/Makefile | 2 +- project_template/tests/__init__.py | 22 ----------------- project_template/tests/run_all.py | 38 ----------------------------- project_template/tests/test_test.py | 12 ++------- 4 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 project_template/tests/__init__.py delete mode 100755 project_template/tests/run_all.py diff --git a/project_template/tests/Makefile b/project_template/tests/Makefile index b990065..0c6125e 100644 --- a/project_template/tests/Makefile +++ b/project_template/tests/Makefile @@ -1,4 +1,4 @@ .PHONY: all all: - ./run_all.py + pytest diff --git a/project_template/tests/__init__.py b/project_template/tests/__init__.py deleted file mode 100644 index 3c09ede..0000000 --- a/project_template/tests/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ - -import unittest - -__all__ = ['TestCase', 'main'] - - -class TestCase(unittest.TestCase): - def setUp(self): - pass - - def tearDown(self): - pass - - -def main(): - try: - unittest.main(testRunner=unittest.TextTestRunner()) - except SystemExit, msg: - result = msg.args[0] - else: - result = 0 - raise SystemExit(result) diff --git a/project_template/tests/run_all.py b/project_template/tests/run_all.py deleted file mode 100755 index 2e217bf..0000000 --- a/project_template/tests/run_all.py +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env python - - -import os -import sys -import subprocess - - -def isexecutable(filename): - infile = open(filename, 'r') - magic = infile.read(2) - infile.close() - return magic == "#!" - - -def collect_tests(): - tests = [] - for dirpath, dirs, files in os.walk("tests"): - tests.extend( - [os.path.join(dirpath, filename) for filename in files - if filename.startswith("test") and filename.endswith(".py") - ]) - return [test[:-3].replace(os.sep, '.') for test in tests - if isexecutable(test)] - - -def main(): - os.chdir(os.path.join(os.path.dirname(sys.argv[0]), os.pardir)) - tests = collect_tests() - - os.environ["PYTHONPATH"] = os.curdir - - for test in sorted(tests): - print test - subprocess.call((sys.executable, '-m', test)) - -if __name__ == '__main__': - main() diff --git a/project_template/tests/test_test.py b/project_template/tests/test_test.py index 1a34012..d4b9c59 100755 --- a/project_template/tests/test_test.py +++ b/project_template/tests/test_test.py @@ -1,14 +1,6 @@ #! /usr/bin/env python -import unittest -from tests import main - - -class TestTest(unittest.TestCase): +class TestTest(object): def test_test(self): - self.assertEqual() - - -if __name__ == "__main__": - main() + assert True -- 2.39.2