Skip to content

Commit

Permalink
Add "tox.ini" and get tests running vs 2.6, 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-rhodes committed Nov 23, 2012
1 parent 330ea4d commit f6d6681
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
12 changes: 5 additions & 7 deletions .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
9 changes: 5 additions & 4 deletions 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):
Expand All @@ -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):
Expand Down
11 changes: 10 additions & 1 deletion src/ephem/tests/test_rst.py
Expand Up @@ -3,6 +3,7 @@
import doctest
import unittest
import os.path
import sys
import time
from glob import glob

Expand All @@ -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)
8 changes: 8 additions & 0 deletions 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

0 comments on commit f6d6681

Please sign in to comment.