summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2012-11-03 12:46:18 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2012-11-03 12:46:18 +0100
commit813782f5f842023c5dcc9658f27f957ca83955eb (patch)
tree9433e2cacf7e51f1c03f6a078ff1781afccb22f1
parentc67a742e01ee7084ffd6ec0d531b96e343e6a5a5 (diff)
downloadsqlparse-813782f5f842023c5dcc9658f27f957ca83955eb.tar.gz
Switch to pytest, it's so much easier.
-rw-r--r--.gitignore1
-rw-r--r--.travis.yml4
-rw-r--r--README.rst6
-rwxr-xr-xtests/run_tests.py70
4 files changed, 8 insertions, 73 deletions
diff --git a/.gitignore b/.gitignore
index 77fe44c..89d6829 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/README.rst b/README.rst
index 0b9086a..ad69fec 100644
--- a/README.rst
+++ b/README.rst
@@ -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)