summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-06-19 22:53:20 +0200
committerJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-06-19 22:53:20 +0200
commitd538523c6ce720b9dd120e3cb9385878afa5dcb7 (patch)
tree780d592a6e416f7e2a89a99b6d1840c0619f4c3a /scripts
parent.gitignore (diff)
downloadg-sorcery-d538523c6ce720b9dd120e3cb9385878afa5dcb7.tar.gz
g-sorcery-d538523c6ce720b9dd120e3cb9385878afa5dcb7.tar.bz2
g-sorcery-d538523c6ce720b9dd120e3cb9385878afa5dcb7.zip
dummy test
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run_tests.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/run_tests.py b/scripts/run_tests.py
new file mode 100755
index 0000000..17395ea
--- /dev/null
+++ b/scripts/run_tests.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ run_tests.py
+ ~~~~~~~~~~~~
+
+ a simple script that runs all the tests from the *tests* directory
+ (.py files)
+
+ :copyright: (c) 2010 by Rafael Goncalves Martins
+ :copyright: (c) 2013 by Jauhien Piatlicki
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import os
+import sys
+import unittest
+
+root_dir = os.path.realpath(os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), '..'
+))
+
+tests_dir = os.path.join(root_dir, 'tests')
+
+# adding the tests directory to the top of the PYTHONPATH
+sys.path = [root_dir, tests_dir] + sys.path
+
+suites = []
+
+# getting the test suites from the python modules (files that ends whit .py)
+for f in os.listdir(tests_dir):
+ if not f.endswith('.py') or not f.startswith('test_'):
+ continue
+ try:
+ my_test = __import__(f[:-len('.py')])
+ except ImportError:
+ continue
+
+ # all the python modules MUST have a 'suite' method, that returns the
+ # test suite of the module
+ suites.append(my_test.suite())
+
+# unifying all the test suites in only one
+suites = unittest.TestSuite(suites)
+
+# creating the Test Runner object
+test_runner = unittest.TextTestRunner(descriptions=2, verbosity=2)
+
+# running the tests
+result = test_runner.run(suites)
+
+if result.failures or result.errors:
+ sys.exit(1)