from __future__ import absolute_import, division, print_function
import os
import unittest
import lsst.utils.tests
def setupAstrometryNetDataDir(name, rootDir=None, verbose=False):
"""Locate the named Astrometry.net data directory from within
the current tree, relative to this file, or relative to the supplied
root directory.
Returns the located data directory and sets the ASTROMETRY_NET_DATA_DIR
environment variable.
"""
17 ↛ 20line 17 didn't jump to line 20, because the condition on line 17 was never false if rootDir is None:
rootDir = os.path.dirname(__file__)
else:
rootDir = os.path.abspath(rootDir)
datapath = os.path.join(rootDir, 'astrometry_net_data', name)
22 ↛ 23line 22 didn't jump to line 23, because the condition on line 22 was never true if not os.path.exists(datapath):
raise ValueError("Need {} version of astrometry_net_data (from path: {})".format(name, datapath))
24 ↛ 25line 24 didn't jump to line 25, because the condition on line 24 was never true if verbose:
print('Setting up astrometry_net_data: {}'.format(datapath))
os.environ["ASTROMETRY_NET_DATA_DIR"] = datapath
return datapath
class TestAstrometryNetDataDirDiscovery(unittest.TestCase):
def setUp(self):
self.datapath = setupAstrometryNetDataDir('photocal')
def test_photocal(self):
self.assertEqual(os.environ["ASTROMETRY_NET_DATA_DIR"], self.datapath)
class MemoryTester(lsst.utils.tests.MemoryTestCase):
pass
def setup_module(module):
lsst.utils.tests.init()
47 ↛ 48line 47 didn't jump to line 48, because the condition on line 47 was never trueif __name__ == "__main__":
lsst.utils.tests.init()
unittest.main()
|