diff --git a/.gitignore b/.gitignore index cf54983d..3dd65ba0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ +/.tox/ +/MANIFEST *.py[co] -*.egg-info -*~ -*.bak -build/ -src/ephem/_libastro.so -src/ephem/doc/_build -tmp*.py +/src/ephem/_libastro.so +/src/ephem/doc/_build +/tmp*.py diff --git a/src/ephem/tests/test_angles.py b/src/ephem/tests/test_angles.py index 62b284d3..e004d924 100644 --- a/src/ephem/tests/test_angles.py +++ b/src/ephem/tests/test_angles.py @@ -1,12 +1,11 @@ #!/usr/bin/env python import unittest -import math from ephem import Angle, degrees, hours # Determine whether angles work reasonably. -arcsecond = 2. * math.pi / 360. / 60. / 60. +arcsecond_places = 5 class AngleTests(unittest.TestCase): def setUp(self): @@ -17,14 +16,16 @@ def test_Angle_constructor(self): self.assertRaises(TypeError, Angle, 1.1) def test_degrees_constructor(self): - self.assertAlmostEqual(self.d, degrees('85:56:37'), delta=arcsecond) + self.assertAlmostEqual(self.d, degrees('85:56:37'), + places=arcsecond_places) def test_degrees_float_value(self): self.assertAlmostEqual(self.d, 1.5) def test_degrees_string_value(self): self.assertEqual(str(self.d), '85:56:37.2') def test_hours_constructor(self): - self.assertAlmostEqual(self.h, hours('6:06:41.6'), delta=arcsecond) + self.assertAlmostEqual(self.h, hours('6:06:41.6'), + places=arcsecond_places) def test_hours_float_value(self): self.assertAlmostEqual(self.h, 1.6) def test_hours_string_value(self): diff --git a/src/ephem/tests/test_rst.py b/src/ephem/tests/test_rst.py index e55abeda..00a43713 100644 --- a/src/ephem/tests/test_rst.py +++ b/src/ephem/tests/test_rst.py @@ -3,6 +3,7 @@ import doctest import unittest import os.path +import sys import time from glob import glob @@ -12,9 +13,17 @@ def load_tests(loader, tests, pattern): os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0' time.tzset() - return unittest.TestSuite([ + # The different floating-point formatting rules in 2.6 and prior + # ruin our doctests. + + tests = [] + + if sys.version_info >= (2, 7): + tests.extend([ doctest.DocFileSuite('../doc/%s' % os.path.basename(path)) for path in glob(os.path.dirname(__file__) + '/../doc/*.rst') if os.path.split(path)[-1] != 'index.rst' # skips time-dependent doctest in index.rst ]) + + return unittest.TestSuite(tests) diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..22a3d8d2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py26, py27 +[testenv] +commands = python -m unittest discover ephem +[testenv:py26] +deps = + unittest2 +commands = unit2 discover ephem