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.
"""
15 ↛ 18line 15 didn't jump to line 18, because the condition on line 15 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)
20 ↛ 21line 20 didn't jump to line 21, because the condition on line 20 was never true if not os.path.exists(datapath):
raise ValueError("Need {} version of astrometry_net_data (from path: {})".format(name, datapath))
22 ↛ 23line 22 didn't jump to line 23, because the condition on line 22 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 test_photocal(self):
datapath = setupAstrometryNetDataDir('t2155')
self.assertEqual(os.environ["ASTROMETRY_NET_DATA_DIR"], datapath)
def setup_module(module):
lsst.utils.tests.init()
class MatchMemoryTestCase(lsst.utils.tests.MemoryTestCase):
pass
43 ↛ 44line 43 didn't jump to line 44, because the condition on line 43 was never trueif __name__ == "__main__":
lsst.utils.tests.init()
unittest.main()
|