diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2012-11-03 12:46:18 +0100 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2012-11-03 12:46:18 +0100 |
| commit | 813782f5f842023c5dcc9658f27f957ca83955eb (patch) | |
| tree | 9433e2cacf7e51f1c03f6a078ff1781afccb22f1 | |
| parent | c67a742e01ee7084ffd6ec0d531b96e343e6a5a5 (diff) | |
| download | sqlparse-813782f5f842023c5dcc9658f27f957ca83955eb.tar.gz | |
Switch to pytest, it's so much easier.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | .travis.yml | 4 | ||||
| -rw-r--r-- | README.rst | 6 | ||||
| -rwxr-xr-x | tests/run_tests.py | 70 |
4 files changed, 8 insertions, 73 deletions
@@ -3,6 +3,7 @@ docs/build dist MANIFEST .coverage +.cache/ extras/appengine/sqlparse extras/appengine/lib/ extras/py3k/sqlparse diff --git a/.travis.yml b/.travis.yml index 08cf9ad..9ddd9c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,6 @@ python: - "2.5" - "2.6" - "2.7" -script: python tests/run_tests.py
\ No newline at end of file +install: + - pip install pytest pytest-cov +script: py.test -v --cov=sqlparse/
\ No newline at end of file @@ -19,9 +19,11 @@ to install python-sqlparse on your system. Run Tests --------- -To run the test suite:: +To run the test suite run:: - python test/run_tests.py + py.test + +Note, you'll need py.test installed. Links diff --git a/tests/run_tests.py b/tests/run_tests.py deleted file mode 100755 index c057216..0000000 --- a/tests/run_tests.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -"""Test runner for sqlparse.""" - -import fnmatch -import optparse -import os -import sys -import unittest - -test_mod = os.path.abspath(os.path.join(os.path.dirname(__file__), '../')) -if test_mod not in sys.path: - sys.path.insert(1, test_mod) - - -parser = optparse.OptionParser() -parser.add_option('-P', '--profile', - help='Create hotshot profile.', - action='store_true', default=False) - - -def _path_matches(path, *patterns): - if not patterns: - return True - for pattern in patterns: - if fnmatch.fnmatch(path, pattern): - return True - return False - - -def _collect_test_modules(base=None, *patterns): - for root, dirnames, filenames in os.walk(os.path.dirname(__file__)): - print root, filenames - for fname in filenames: - if not fname.endswith('.py'): - continue - elif not _path_matches(os.path.join(root, fname), *patterns): - continue - if not root in sys.path: - sys.path.append(root) - modname = os.path.splitext(fname)[0] - yield __import__(modname) - - -def main(args): - """Create a TestSuite and run it.""" - loader = unittest.TestLoader() - suite = unittest.TestSuite() - for mod in _collect_test_modules(*args): - suite.addTests(loader.loadTestsFromModule(mod)) - return unittest.TextTestRunner(verbosity=2).run(suite) - - - - -if __name__ == '__main__': - opts, args = parser.parse_args() - if opts.profile: - import hotshot - prof = hotshot.Profile("sqlparse.prof") - prof.runcall(main, args) - prof.close() - else: - result = main(args) - if not result.wasSuccessful(): - return_code = 1 - else: - return_code = 0 - sys.exit(return_code) |
