Coverage for tests/test_astropyTableFormatter.py: 43%
28 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-04-13 02:34 -0700
« prev ^ index » next coverage.py v6.5.0, created at 2023-04-13 02:34 -0700
1# This file is part of daf_butler.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22"""Tests for AstropyTableFormatter.
23"""
25import os
26import unittest
28import numpy
29from astropy.table import Table
30from lsst.daf.butler import Butler, DatasetType
31from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir
33TESTDIR = os.path.abspath(os.path.dirname(__file__))
36class AstropyTableFormatterTestCase(unittest.TestCase):
37 """Test for AstropyTableFormatter."""
39 def setUp(self):
40 self.root = makeTestTempDir(TESTDIR)
41 Butler.makeRepo(self.root)
42 ints = [1, 2, 3]
43 names = ["one", "two", "three"]
44 transcendentals = [3.14, 2.718, 0.643]
45 self.table = Table([ints, names, transcendentals], names=["ints", "names", "transcendentals"])
47 def tearDown(self):
48 removeTestTempDir(self.root)
49 del self.table
51 def testAstropyTableFormatter(self):
52 butler = Butler(self.root, run="testrun")
53 datasetType = DatasetType("table", [], "AstropyTable", universe=butler.registry.dimensions)
54 butler.registry.registerDatasetType(datasetType)
55 ref = butler.put(self.table, datasetType)
56 uri = butler.getURI(ref)
57 self.assertEqual(uri.getExtension(), ".ecsv")
58 table = butler.get("table")
59 self.assertTrue(numpy.all(table == self.table))
62if __name__ == "__main__":
63 unittest.main()