summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHernan Grecco <hernan.grecco@gmail.com>2014-05-08 00:50:13 -0300
committerHernan Grecco <hernan.grecco@gmail.com>2014-05-08 00:50:13 -0300
commit7f9ee50db7c1c8844200f032430d8cac5037ee82 (patch)
treee18fcc33871c8b7606d621b381175f45b07737c4
parentcf4c8e71d8a639c53bd06278b5384c45cc97b44a (diff)
downloadpint-7f9ee50db7c1c8844200f032430d8cac5037ee82.tar.gz
Added test function at the package level to run all tests.
-rw-r--r--docs/getting.rst7
-rw-r--r--pint/__init__.py5
-rw-r--r--pint/compat/__init__.py5
-rw-r--r--pint/testsuite/__init__.py5
4 files changed, 19 insertions, 3 deletions
diff --git a/docs/getting.rst b/docs/getting.rst
index a845d6b..9b616e3 100644
--- a/docs/getting.rst
+++ b/docs/getting.rst
@@ -16,11 +16,18 @@ or using easy_install_::
That's all! You can check that Pint is correctly installed by starting up python, and importing pint:
>>> import pint
+ >>> pint.__version__
+ 0.5
.. note:: If you have an old system installation of Python and you don't want to
mess with it, you can try `Anaconda CE`_. It is a free Python distribution by
Continuum Analytics that includes many scientific packages.
+You can check the installation with the following command:
+
+ >>> pint.test()
+
+
On Arch Linux, you can alternatively install Pint from the Arch User Repository
(AUR). The latest release is available as `python-pint`_, and packages tracking
the master branch of the GitHub repository are available as `python-pint-git`_
diff --git a/pint/__init__.py b/pint/__init__.py
index a89697b..d616980 100644
--- a/pint/__init__.py
+++ b/pint/__init__.py
@@ -55,3 +55,8 @@ def run_pyroma(data): # pragma: no cover
except ImportError:
if not ask("pyroma not available. Continue?"):
sys.exit(1)
+
+
+def test():
+ from .testsuite import run
+ run()
diff --git a/pint/compat/__init__.py b/pint/compat/__init__.py
index a6fb743..ed5c255 100644
--- a/pint/compat/__init__.py
+++ b/pint/compat/__init__.py
@@ -42,7 +42,10 @@ else:
maketrans = lambda f, t: dict((ord(a), b) for a, b in zip(f, t))
if sys.version_info < (2, 7):
- import unittest2 as unittest
+ try:
+ import unittest2 as unittest
+ except ImportError:
+ raise Exception("Testing Pint in Python 2.6 requires package 'unittest2'")
else:
import unittest
diff --git a/pint/testsuite/__init__.py b/pint/testsuite/__init__.py
index c0a6b4a..1ad5bf5 100644
--- a/pint/testsuite/__init__.py
+++ b/pint/testsuite/__init__.py
@@ -124,7 +124,8 @@ def testsuite():
def main():
- """Runs the testsuite as command line application."""
+ """Runs the testsuite as command line application.
+ """
try:
unittest.main()
except Exception as e:
@@ -132,7 +133,7 @@ def main():
def run():
- """Run all tests i
+ """Run all tests.
"""
test_runner = unittest.TextTestRunner()
test_runner.run(testsuite())