Skip to content

Commit

Permalink
Merge pull request #105 from lsst/tickets/DM-16550
Browse files Browse the repository at this point in the history
DM-16550: Fix race condition in YAML test
  • Loading branch information
timj committed Nov 26, 2018
2 parents 4477fe7 + e9a2413 commit 7649090
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
14 changes: 8 additions & 6 deletions tests/test_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ def testV1withV2InitApiRaises(self):
"""Test that a RuntimeError is raised when Butler v1 init api (root,
mapper, mapperArgs**) is used with Butler v2 init api
(inputs, outputs)."""
foobar = os.path.join(self.testDir, "bar")
foobaz = os.path.join(self.testDir, "baz")
with self.assertRaises(RuntimeError):
dp.Butler(root='foo/bar', inputs='foo/bar')
dp.Butler(root=foobar, inputs=foobar)
with self.assertRaises(RuntimeError):
dp.Butler(mapper='lsst.obs.base.CameraMapper', inputs='foo/bar')
dp.Butler(mapper='lsst.obs.base.CameraMapper', inputs=foobar)
with self.assertRaises(RuntimeError):
dp.Butler(inputs='foo/bar', calibRoot='foo/baz')
dp.Butler(inputs=foobar, calibRoot=foobaz)
with self.assertRaises(RuntimeError):
dp.Butler(root='foo/bar', outputs='foo/bar')
dp.Butler(root=foobar, outputs=foobar)
with self.assertRaises(RuntimeError):
dp.Butler(mapper='lsst.obs.base.CameraMapper', outputs='foo/bar')
dp.Butler(mapper='lsst.obs.base.CameraMapper', outputs=foobar)
with self.assertRaises(RuntimeError):
dp.Butler(inputs='foo/bar', outputs='foo/baz')
dp.Butler(inputs=foobar, outputs=foobaz)

def testV1RepoWithRootOnly(self):
repoDir = os.path.join(self.testDir, 'repo')
Expand Down
5 changes: 2 additions & 3 deletions tests/test_butlerPickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@
import shutil
import tempfile
import lsst.utils.tests
import os

import lsst.daf.persistence as dafPersist


class MinMapper(dafPersist.Mapper):

def __init__(self, root, parentRegistry, repositoryCfg):
pass
self.root = root

def map_x(self, dataId, write):
path = "foo%(ccd)d.pickle" % dataId
return dafPersist.ButlerLocation(
None, None, "PickleStorage", path, {},
self, dafPersist.Storage.makeFromURI(os.getcwd()))
self, dafPersist.Storage.makeFromURI(self.root))


class ButlerPickleTestCase(unittest.TestCase):
Expand Down
15 changes: 4 additions & 11 deletions tests/test_butlerYaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import shutil
import tempfile
import lsst.utils.tests
import os

import lsst.daf.persistence as dafPersist
import lsst.daf.base as dafBase
Expand All @@ -34,13 +33,13 @@
class MinMapper(dafPersist.Mapper):

def __init__(self, root, parentRegistry, repositoryCfg):
pass
self.root = root

def map_x(self, dataId, write):
path = "foo%(ccd)d.yaml" % dataId
return dafPersist.ButlerLocation(
"lsst.daf.base.PropertySet", "PropertySet", "YamlStorage",
[path], dataId, self, dafPersist.Storage.makeFromURI(os.getcwd()))
[path], dataId, self, dafPersist.Storage.makeFromURI(self.root))


class ButlerYamlTestCase(unittest.TestCase):
Expand Down Expand Up @@ -74,10 +73,7 @@ def testPropertySet(self):
pset.setFloat("float2", -1.234)
self.butler.put(pset, self.localTypeName, ccd=3)
y = self.butler.get(self.localTypeName, ccd=3, immediate=True)
self.assertEqual(set(pset.names(False)), set(y.names(False)))
for i in pset.paramNames(False):
self.assertEqual(pset.getArray(i), y.getArray(i))
self.assertEqual(pset.typeOf(i), y.typeOf(i))
self.assertEqual(y, pset)

def testPropertyList(self):
plist = dafBase.PropertyList()
Expand All @@ -95,10 +91,7 @@ def testPropertyList(self):
plist.setFloat("float2", -1.234)
self.butler.put(plist, self.localTypeName, ccd=3)
y = self.butler.get(self.localTypeName, ccd=3, immediate=True)
self.assertEqual(plist.names(False), y.names(False))
for i in plist.names(False):
self.assertEqual(plist.getArray(i), y.getArray(i))
self.assertEqual(plist.typeOf(i), y.typeOf(i))
self.assertEqual(y, plist)


class TestMemory(lsst.utils.tests.MemoryTestCase):
Expand Down

0 comments on commit 7649090

Please sign in to comment.