コード例 #1
0
    def test3Methods(self):
        """Test various methods of CfgKeyStore"""
        ks = CfgKeyStore("MyStore")
        self.failUnless(ks.streamESD() == [])
        self.failUnless(ks['streamESD']() == [])
        ks.streamESD.add({
            'McEventCollection': ['GEN_EVENT', 'GEN_AOD', 'TruthEvent'],
        })
        self.failUnless(len(ks.streamESD()) == 3)
        self.failUnless(len(ks.transient()) == 3)
        self.failUnless(ks.streamESD.has_item('McEventCollection#TruthEvent'))
        self.failUnless(not ks.streamESD.has_item('McEventCollection#gen_aod'))

        ks.streamAOD += CfgItemList('subAod',
                                    items=['Klass#key1', 'Klass#key2'])
        self.failUnless(len(ks.streamAOD()) == 2)
        self.failUnless(len(ks.transient()) == 5)

        ks.streamESD.add({
            'JetCollection':
            ['Cone4Jets', 'Cone7Jets', 'KtJets', 'Cone4TruthJets'],
        })
        self.failUnless(len(ks.streamESD()) == 3 + 4)
        self.failUnless(len(ks.streamESD.dict().keys()) == 2)
        self.failUnless(len(ks.transient.dict().keys()) == 3)

        ks.streamESD.add(
            {'JetCollection': ['Cone4Jets', 'Cone7Jets', 'KtJets']})
        self.failUnless(len(ks.streamESD()) == 3 + 4)
        self.failUnless(len(ks.streamESD.dict().keys()) == 2)
        self.failUnless(len(ks.transient.dict().keys()) == 3)

        ks.streamAOD.add('ParticleJetContainer#ConeTowerParticleJets')
        self.failUnless(len(ks.streamAOD()) == 3)
        self.failUnless(len(ks.streamAOD.dict().keys()) == 2)
        self.failUnless(len(ks.transient.dict().keys()) == 4)

        ks.streamAOD.add(['ParticleJetContainer#ConeTowerParticleJets'])
        self.failUnless(len(ks.streamAOD()) == 3)
        self.failUnless(len(ks.streamAOD.dict().keys()) == 2)
        self.failUnless(len(ks.transient.dict().keys()) == 4)

        ks.streamAOD.add(['ParticleJetContainer#Cone4TowerParticleJets'])
        self.failUnless(len(ks.streamAOD()) == 4)
        self.failUnless(len(ks.streamAOD.dict().keys()) == 2)
        self.failUnless(len(ks.transient.dict().keys()) == 4)

        caught = False
        try:
            ks['unallowedKey'] = range(10)
        except KeyError, err:
            caught = True
コード例 #2
0
    def test3Methods( self ):
        """Test various methods of CfgKeyStore"""
        ks = CfgKeyStore( "MyStore" )
        self.failUnless( ks.streamESD()    == [] )
        self.failUnless( ks['streamESD']() == [] )
        ks.streamESD.add( {
            'McEventCollection' : [ 'GEN_EVENT', 'GEN_AOD', 'TruthEvent' ],
            } )
        self.failUnless( len(ks.streamESD()) == 3 )
        self.failUnless( len(ks.transient()) == 3 )
        self.failUnless(ks.streamESD.has_item('McEventCollection#TruthEvent'))
        self.failUnless(not ks.streamESD.has_item('McEventCollection#gen_aod'))

        ks.streamAOD += CfgItemList( 'subAod',
                                     items = [ 'Klass#key1', 'Klass#key2' ] )
        self.failUnless( len(ks.streamAOD()) == 2 )
        self.failUnless( len(ks.transient()) == 5 )

        ks.streamESD.add( {
            'JetCollection' : [ 'Cone4Jets', 'Cone7Jets', 'KtJets',
                                'Cone4TruthJets' ],
            } )
        self.failUnless( len(ks.streamESD()) == 3+4 )
        self.failUnless( len(ks.streamESD.dict().keys()) == 2 )
        self.failUnless( len(ks.transient.dict().keys()) == 3 )
        
        ks.streamESD.add( {
            'JetCollection' : [ 'Cone4Jets', 'Cone7Jets', 'KtJets' ] } )
        self.failUnless( len(ks.streamESD()) == 3+4 )
        self.failUnless( len(ks.streamESD.dict().keys()) == 2 )
        self.failUnless( len(ks.transient.dict().keys()) == 3 )

        ks.streamAOD.add( 'ParticleJetContainer#ConeTowerParticleJets' )
        self.failUnless( len(ks.streamAOD())             == 3 )
        self.failUnless( len(ks.streamAOD.dict().keys()) == 2 )
        self.failUnless( len(ks.transient.dict().keys()) == 4 )

        ks.streamAOD.add( ['ParticleJetContainer#ConeTowerParticleJets'] )
        self.failUnless( len(ks.streamAOD())             == 3 )
        self.failUnless( len(ks.streamAOD.dict().keys()) == 2 )
        self.failUnless( len(ks.transient.dict().keys()) == 4 )
        
        ks.streamAOD.add( ['ParticleJetContainer#Cone4TowerParticleJets'] )
        self.failUnless( len(ks.streamAOD())             == 4 )
        self.failUnless( len(ks.streamAOD.dict().keys()) == 2 )
        self.failUnless( len(ks.transient.dict().keys()) == 4 )

        caught = False
        try:
            ks['unallowedKey'] = range(10)
        except KeyError, err:
            caught = True
コード例 #3
0
    def test2Constructor(self):
        """Test constructor"""
        ks = CfgKeyStore("MyStore")

        self.failUnless(ks.name() == "MyStore")
        self.failUnless(len(ks.keys()) == len(ks._items) + 4)
        for label in ks.keys():
            if label == 'transient': n = 4  # nbr of streamXyz
            else: n = 0
            self.failUnless(len(ks[label]) == n)
            self.failUnless(len(ks[label].list()) == 0)
            self.failUnless(hasattr(ks, label))

        ks.streamAOD.add({'Klass': 'key1'})
        self.failUnless(ks.streamAOD() == ['Klass#key1'])
        del ks

        ks = CfgKeyStore("MyStore")
        self.failUnless(ks.streamAOD() == [])

        pass
コード例 #4
0
    def test2Constructor( self ):
        """Test constructor"""
        ks = CfgKeyStore( "MyStore" )

        self.failUnless( ks.name() == "MyStore" )
        self.failUnless( len(ks.keys()) == len(ks._items)+4 )
        for label in ks.keys():
            if label == 'transient': n = 4 # nbr of streamXyz
            else : n = 0
            self.failUnless( len(ks[label])        == n )
            self.failUnless( len(ks[label].list()) == 0 )
            self.failUnless( hasattr(ks, label) )

        ks.streamAOD.add( { 'Klass' : 'key1' } )
        self.failUnless( ks.streamAOD() == [ 'Klass#key1' ] )
        del ks

        ks = CfgKeyStore( "MyStore" )
        self.failUnless( ks.streamAOD() == [] )
        
        pass
コード例 #5
0
    def test6KeyStoreDiff(self):
        """Test keystore_diff"""
        from AthenaCommon.KeyStore import keystore_diff

        # reference
        ref = CfgKeyStore("ref")
        self.failUnless(ref.streamESD() == [])
        self.failUnless(ref.streamAOD() == [])
        self.failUnless(ref.transient() == [])
        ref.streamESD.add({
            'McEvent': ['GEN_EVENT', 'GEN_AOD', 'TruthEvent'],
            'NoEvent': ['GEN_EVENT', 'GEN_AOD', 'TruthEvent'],
        })
        self.failUnless(len(ref.streamESD()) == 6)
        self.failUnless(len(ref.streamAOD()) == 0)
        self.failUnless(len(ref.transient()) == 6)

        # check
        chk = CfgKeyStore("chk")
        self.failUnless(chk.streamESD() == [])
        self.failUnless(chk.streamAOD() == [])
        self.failUnless(chk.transient() == [])
        chk.streamESD.add({
            'NoEvent': ['GEN_EVENT', 'TruthEvent'],
        })
        self.failUnless(len(chk.streamESD()) == 2)
        self.failUnless(len(chk.streamAOD()) == 0)
        self.failUnless(len(chk.transient()) == 2)

        diff_ref = "".join([
            "- len(ref[streamESD]) == 6", "+ len(chk[streamESD]) == 2",
            "- ref[streamESD] : McEvent#GEN_AOD",
            "- ref[streamESD] : McEvent#GEN_EVENT",
            "- ref[streamESD] : McEvent#TruthEvent",
            "- ref[streamESD] : NoEvent#GEN_AOD", ""
        ])

        import os, atexit

        test1_fname = 'test1_%s.diff' % str(os.getpid())
        otest1 = open(test1_fname, 'w')
        atexit.register(os.unlink, test1_fname)
        diff = keystore_diff(ref, chk, labels='streamESD', ofile=otest1)
        self.failUnless(diff == diff_ref)
        self.failUnless(os.path.exists(test1_fname))
        diff = keystore_diff("ref", "chk", labels='streamESD', ofile=otest1)
        self.failUnless(diff == diff_ref)
        self.failUnless(os.path.exists(test1_fname))

        test2_fname = 'test2_%s.diff' % str(os.getpid())
        otest2 = open(test2_fname, 'w')
        atexit.register(os.unlink, test2_fname)
        diff_ref = "".join([
            "- len(ref[transient]) == 6", "+ len(chk[transient]) == 2",
            "- ref[transient] : McEvent#GEN_AOD",
            "- ref[transient] : McEvent#GEN_EVENT",
            "- ref[transient] : McEvent#TruthEvent",
            "- ref[transient] : NoEvent#GEN_AOD", "- len(ref[streamESD]) == 6",
            "+ len(chk[streamESD]) == 2", "- ref[streamESD] : McEvent#GEN_AOD",
            "- ref[streamESD] : McEvent#GEN_EVENT",
            "- ref[streamESD] : McEvent#TruthEvent",
            "- ref[streamESD] : NoEvent#GEN_AOD", ""
        ])
        diff = keystore_diff(ref, chk, ofile=otest2)
        self.failUnless(diff == diff_ref)
        self.failUnless(os.path.exists(test2_fname))
        diff = keystore_diff("ref", "chk", ofile=otest2)
        self.failUnless(diff == diff_ref)
        self.failUnless(os.path.exists(test2_fname))

        test3_fname = 'test3_%s.diff' % str(os.getpid())
        otest3 = open(test3_fname, 'w')
        atexit.register(os.unlink, test3_fname)
        diff = keystore_diff(ref, ref, otest3)
        self.failUnless(diff == '')
        self.failUnless(os.path.exists(test3_fname))
        diff = keystore_diff("ref", "ref", otest3)
        self.failUnless(diff == '')

        ## valid arguments...
        err_msg = None
        test4_fname = 'test4_%s.diff' % str(os.getpid())
        otest4 = open(test4_fname, 'w')
        atexit.register(os.unlink, test4_fname)
        try:
            diff = keystore_diff("ref", "typo-chk", ofile=otest4)
        except ValueError, err:
            err_msg = str(err)
コード例 #6
0
    def test4Persistency(self):
        """Test persistency of CfgKeyStore"""
        ks = CfgKeyStore("MyStore")
        self.failUnless(ks.streamESD() == [])
        self.failUnless(ks.streamAOD() == [])
        self.failUnless(ks.transient() == [])
        ks.streamESD.add({
            'McEventCollection': ['GEN_EVENT', 'GEN_AOD', 'TruthEvent'],
        })
        self.failUnless(len(ks.streamESD()) == 3)
        self.failUnless(len(ks.streamAOD()) == 0)
        self.failUnless(len(ks.transient()) == 3)

        import os
        outFileName = 'esd_%s.py' % str(os.getpid())
        ks.write(outFileName, 'streamESD')

        del ks
        ks = CfgKeyStore("MyStore")
        self.failUnless(ks.streamESD() == [])
        self.failUnless(ks.streamAOD() == [])
        self.failUnless(ks.transient() == [])

        ks.read(outFileName, 'streamAOD')
        self.failUnless(len(ks.streamESD()) == 0)
        self.failUnless(len(ks.streamAOD()) == 3)
        self.failUnless(len(ks.transient()) == 3)

        del ks
        ks = CfgKeyStore("MyStore")
        self.failUnless(ks.streamESD() == [])
        self.failUnless(ks.streamAOD() == [])
        self.failUnless(ks.transient() == [])

        ks.read(outFileName, 'streamAOD')
        self.failUnless(len(ks.streamESD()) == 0)
        self.failUnless(len(ks.streamAOD()) == 3)
        self.failUnless(len(ks.transient()) == 3)

        del ks
        ks = CfgKeyStore("MyStore")
        self.failUnless(ks.streamESD() == [])
        self.failUnless(ks.streamAOD() == [])
        self.failUnless(ks.transient() == [])

        ks.read(outFileName, 'streamESD')
        self.failUnless(len(ks.streamESD()) == 3)
        self.failUnless(len(ks.streamAOD()) == 0)
        self.failUnless(len(ks.transient()) == 3)

        del ks
        ks = CfgKeyStore("MyStore")
        self.failUnless(ks.streamESD() == [])
        self.failUnless(ks.streamAOD() == [])
        self.failUnless(ks.transient() == [])

        ks.read(outFileName, 'streamESD')
        ks.read(outFileName, 'streamAOD')
        self.failUnless(len(ks.streamESD()) == 3)
        self.failUnless(len(ks.streamAOD()) == 3)
        self.failUnless(len(ks.transient()) == 3)

        os.remove(outFileName)
        os.remove(outFileName + 'c')

        import shelve
        outFileName = 'esd_%s.dat' % str(os.getpid())

        del ks
        ks = CfgKeyStore("MyStore")
        ks.streamESD.add({
            'McEventCollection': ['GEN_EVENT', 'GEN_AOD', 'TruthEvent'],
        })
        self.failUnless(len(ks.streamESD()) == 3)
        self.failUnless(len(ks.streamAOD()) == 0)
        self.failUnless(len(ks.transient()) == 3)

        print 'outFileName:', outFileName
        db = shelve.open(outFileName, 'c')
        db['store'] = ks
        db.close()

        del ks
        db = shelve.open(outFileName, 'r')
        ks = db['store']
        db.close()

        self.failUnless(len(ks.streamESD()) == 3)
        self.failUnless(len(ks.streamAOD()) == 0)
        self.failUnless(len(ks.transient()) == 3)
        ## MacOSX silently appends the .db suffix to shelve files. I haven't found a
        ## mechanism for determining the actual filename, which is why I've added the
        ## MacOSX-specific hack.
        from sys import platform
        if platform != 'darwin':
            os.remove(outFileName)
        else:
            os.remove(outFileName + '.db')
コード例 #7
0
# MC Truth for PileUp
AOD_ItemList += ["PileUpEventInfo#*"]

#obsolete AOD_ItemList+=[ "DetStatusMap#DetectorStatus" ]

if AODFlags.Trigger:
    include("TriggerRelease/TriggerOutputItemListAOD_jobOptions.py")

# now merge the explicit AOD list to the one coming from ObjKeyStore
# (more and more will be taken from ObjKeyStore)
from AthenaCommon.KeyStore import CfgItemList, CfgKeyStore
theCKS = CfgKeyStore("KeyStore")
CILMergeAOD = CfgItemList("AODMerge", allowWildCard=True)
CILMergeAOD.add(AOD_ItemList)
CILMergeAOD.add(theCKS.streamAOD())

#now prune the itemlist from the object which are soft linked

# this doe not work CILMergeAOD.remove("DataVector<INavigable4Momentum>")
#this does
for k in CILMergeAOD('DataVector<INavigable4Momentum>'):
    CILMergeAOD.removeItem(k)

# The only items declared in StreamESD are those written here.
# Note the use of "=" instead of "+=" is deliberate
#StreamESD.ItemList = fullESDList()

AOD_ItemList = CILMergeAOD()

#print "ESD Output list is :",StreamESD.ItemList
コード例 #8
0
    def test3Methods( self ):
        """Test various methods of CfgKeyStore"""
        ks = CfgKeyStore( "MyStore" )
        self.assertTrue( ks.streamESD()    == [] )
        self.assertTrue( ks['streamESD']() == [] )
        ks.streamESD.add( {
            'McEventCollection' : [ 'GEN_EVENT', 'GEN_AOD', 'TruthEvent' ],
            } )
        self.assertTrue( len(ks.streamESD()) == 3 )
        self.assertTrue( len(ks.transient()) == 3 )
        self.assertTrue(ks.streamESD.has_item('McEventCollection#TruthEvent'))
        self.assertTrue(not ks.streamESD.has_item('McEventCollection#gen_aod'))

        ks.streamAOD += CfgItemList( 'subAod',
                                     items = [ 'Klass#key1', 'Klass#key2' ] )
        self.assertTrue( len(ks.streamAOD()) == 2 )
        self.assertTrue( len(ks.transient()) == 5 )

        ks.streamESD.add( {
            'JetCollection' : [ 'Cone4Jets', 'Cone7Jets', 'KtJets',
                                'Cone4TruthJets' ],
            } )
        self.assertTrue( len(ks.streamESD()) == 3+4 )
        self.assertTrue( len(ks.streamESD.dict().keys()) == 2 )
        self.assertTrue( len(ks.transient.dict().keys()) == 3 )
        
        ks.streamESD.add( {
            'JetCollection' : [ 'Cone4Jets', 'Cone7Jets', 'KtJets' ] } )
        self.assertTrue( len(ks.streamESD()) == 3+4 )
        self.assertTrue( len(ks.streamESD.dict().keys()) == 2 )
        self.assertTrue( len(ks.transient.dict().keys()) == 3 )

        ks.streamAOD.add( 'ParticleJetContainer#ConeTowerParticleJets' )
        self.assertTrue( len(ks.streamAOD())             == 3 )
        self.assertTrue( len(ks.streamAOD.dict().keys()) == 2 )
        self.assertTrue( len(ks.transient.dict().keys()) == 4 )

        ks.streamAOD.add( ['ParticleJetContainer#ConeTowerParticleJets'] )
        self.assertTrue( len(ks.streamAOD())             == 3 )
        self.assertTrue( len(ks.streamAOD.dict().keys()) == 2 )
        self.assertTrue( len(ks.transient.dict().keys()) == 4 )
        
        ks.streamAOD.add( ['ParticleJetContainer#Cone4TowerParticleJets'] )
        self.assertTrue( len(ks.streamAOD())             == 4 )
        self.assertTrue( len(ks.streamAOD.dict().keys()) == 2 )
        self.assertTrue( len(ks.transient.dict().keys()) == 4 )

        caught = False
        try:
            ks['unallowedKey'] = range(10)
        except KeyError as err:
            caught = True
        self.assertTrue( caught )

        caught = False
        try:                  dummy = ks['unallowedKey']
        except KeyError as err: caught = True
        self.assertTrue( caught )

        caught = False
        try:                  dummy = ks['streamAOD']
        except KeyError as err: caught = True
        self.assertTrue( not caught )
        del dummy

        ## test reset...
        ks.streamTAG.add( 'JetCollection#Tag_Cone4Jets' )
        self.assertTrue( len(ks.streamTAG()) == 1 )
        ks.streamTAG.clear()
        self.assertTrue( len(ks.streamTAG()) == 0 )

        self.assertTrue( len(ks.streamAOD.dict().keys()) == 2 )
        self.assertTrue( len(ks.transient.dict().keys()) == 4 )

        ks.transient.clear()
        self.assertTrue( len(ks.transient.dict().keys()) == 0 )
        ## might be a bit confusing but 'clear' also removes children
        caught = False
        try:                        dummy = ks.streamAOD
        except AttributeError as err: caught = True
        self.assertTrue( caught )

        self.assertTrue( len(list(CfgKeyStore.instances.keys())) == 1 )

        del ks
        ## FIXME
        ## ARGH!!! Somebody is keeping a ref toward ks!
        ## OK with py3
        if six.PY3:
            self.assertTrue( len(list(CfgKeyStore.instances.keys())) == 0 )
コード例 #9
0
    def test6KeyStoreDiff( self ):
        """Test keystore_diff"""
        from AthenaCommon.KeyStore import keystore_diff
        
        # reference
        ref = CfgKeyStore( "ref" )
        self.failUnless( ref.streamESD() == [] )
        self.failUnless( ref.streamAOD() == [] )
        self.failUnless( ref.transient() == [] )
        ref.streamESD.add( {
            'McEvent' : [ 'GEN_EVENT', 'GEN_AOD', 'TruthEvent' ],
            'NoEvent' : [ 'GEN_EVENT', 'GEN_AOD', 'TruthEvent' ],
            } )
        self.failUnless( len(ref.streamESD()) == 6 )
        self.failUnless( len(ref.streamAOD()) == 0 )
        self.failUnless( len(ref.transient()) == 6 )

        # check
        chk = CfgKeyStore( "chk" )
        self.failUnless( chk.streamESD() == [] )
        self.failUnless( chk.streamAOD() == [] )
        self.failUnless( chk.transient() == [] )
        chk.streamESD.add( {
            'NoEvent' : [ 'GEN_EVENT', 'TruthEvent' ],
            } )
        self.failUnless( len(chk.streamESD()) == 2 )
        self.failUnless( len(chk.streamAOD()) == 0 )
        self.failUnless( len(chk.transient()) == 2 )

        diff_ref = "".join ([
            "- len(ref[streamESD]) == 6",
            "+ len(chk[streamESD]) == 2",
            "- ref[streamESD] : McEvent#GEN_AOD",
            "- ref[streamESD] : McEvent#GEN_EVENT",
            "- ref[streamESD] : McEvent#TruthEvent",
            "- ref[streamESD] : NoEvent#GEN_AOD",
            ""
            ])

        import os,atexit
        
        test1_fname = 'test1_%s.diff' % str(os.getpid())
        otest1 = open (test1_fname, 'w')
        atexit.register (os.unlink, test1_fname)
        diff = keystore_diff (ref, chk, labels='streamESD', ofile=otest1)
        self.failUnless (diff==diff_ref)
        self.failUnless (os.path.exists (test1_fname))
        diff = keystore_diff ("ref", "chk", labels='streamESD', ofile=otest1)
        self.failUnless (diff==diff_ref)
        self.failUnless (os.path.exists (test1_fname))
        

        test2_fname = 'test2_%s.diff' % str(os.getpid())
        otest2 = open (test2_fname, 'w')
        atexit.register (os.unlink, test2_fname)
        diff_ref = "".join ([
            "- len(ref[transient]) == 6",
            "+ len(chk[transient]) == 2",
            "- ref[transient] : McEvent#GEN_AOD",
            "- ref[transient] : McEvent#GEN_EVENT",
            "- ref[transient] : McEvent#TruthEvent",
            "- ref[transient] : NoEvent#GEN_AOD",
            "- len(ref[streamESD]) == 6",
            "+ len(chk[streamESD]) == 2",
            "- ref[streamESD] : McEvent#GEN_AOD",
            "- ref[streamESD] : McEvent#GEN_EVENT",
            "- ref[streamESD] : McEvent#TruthEvent",
            "- ref[streamESD] : NoEvent#GEN_AOD",
            ""
            ])
        diff = keystore_diff (ref, chk, ofile=otest2)
        self.failUnless (diff==diff_ref)
        self.failUnless (os.path.exists (test2_fname))
        diff = keystore_diff ("ref", "chk", ofile=otest2)
        self.failUnless (diff==diff_ref)
        self.failUnless (os.path.exists (test2_fname))

        test3_fname = 'test3_%s.diff' % str(os.getpid())
        otest3 = open (test3_fname, 'w')
        atexit.register (os.unlink, test3_fname)
        diff = keystore_diff (ref, ref, otest3)
        self.failUnless (diff=='')
        self.failUnless (os.path.exists (test3_fname))
        diff = keystore_diff ("ref", "ref", otest3)
        self.failUnless (diff=='')
        
        ## valid arguments...
        err_msg = None
        test4_fname = 'test4_%s.diff' % str(os.getpid())
        otest4 = open (test4_fname, 'w')
        atexit.register (os.unlink, test4_fname)
        try:
            diff = keystore_diff ("ref", "typo-chk", ofile=otest4)
        except ValueError, err:
            err_msg = str(err)
コード例 #10
0
    def test4Persistency( self ):
        """Test persistency of CfgKeyStore"""
        ks = CfgKeyStore( "MyStore" )
        self.failUnless( ks.streamESD() == [] )
        self.failUnless( ks.streamAOD() == [] )
        self.failUnless( ks.transient() == [] )
        ks.streamESD.add( {
            'McEventCollection' : [ 'GEN_EVENT', 'GEN_AOD', 'TruthEvent' ],
            } )
        self.failUnless( len(ks.streamESD()) == 3 )
        self.failUnless( len(ks.streamAOD()) == 0 )
        self.failUnless( len(ks.transient()) == 3 )

        import os
        outFileName = 'esd_%s.py' % str(os.getpid())
        ks.write( outFileName, 'streamESD' )

        del ks
        ks = CfgKeyStore( "MyStore" )
        self.failUnless( ks.streamESD() == [] )
        self.failUnless( ks.streamAOD() == [] )
        self.failUnless( ks.transient() == [] )

        ks.read( outFileName, 'streamAOD' )
        self.failUnless( len(ks.streamESD()) == 0 )
        self.failUnless( len(ks.streamAOD()) == 3 )
        self.failUnless( len(ks.transient()) == 3 )

        del ks
        ks = CfgKeyStore( "MyStore" )
        self.failUnless( ks.streamESD() == [] )
        self.failUnless( ks.streamAOD() == [] )
        self.failUnless( ks.transient() == [] )

        ks.read( outFileName, 'streamAOD' )
        self.failUnless( len(ks.streamESD()) == 0 )
        self.failUnless( len(ks.streamAOD()) == 3 )
        self.failUnless( len(ks.transient()) == 3 )

        del ks
        ks = CfgKeyStore( "MyStore" )
        self.failUnless( ks.streamESD() == [] )
        self.failUnless( ks.streamAOD() == [] )
        self.failUnless( ks.transient() == [] )

        ks.read( outFileName, 'streamESD' )
        self.failUnless( len(ks.streamESD()) == 3 )
        self.failUnless( len(ks.streamAOD()) == 0 )
        self.failUnless( len(ks.transient()) == 3 )

        del ks
        ks = CfgKeyStore( "MyStore" )
        self.failUnless( ks.streamESD() == [] )
        self.failUnless( ks.streamAOD() == [] )
        self.failUnless( ks.transient() == [] )

        ks.read( outFileName, 'streamESD' )
        ks.read( outFileName, 'streamAOD' )
        self.failUnless( len(ks.streamESD()) == 3 )
        self.failUnless( len(ks.streamAOD()) == 3 )
        self.failUnless( len(ks.transient()) == 3 )

        os.remove( outFileName )
        os.remove( outFileName+'c' )

        import shelve
        outFileName = 'esd_%s.dat' % str(os.getpid())

        del ks
        ks = CfgKeyStore( "MyStore" )
        ks.streamESD.add( {
            'McEventCollection' : [ 'GEN_EVENT', 'GEN_AOD', 'TruthEvent' ],
            } )
        self.failUnless( len(ks.streamESD()) == 3 )
        self.failUnless( len(ks.streamAOD()) == 0 )
        self.failUnless( len(ks.transient()) == 3 )

        print 'outFileName:',outFileName
        db = shelve.open( outFileName, 'c' )
        db['store'] = ks
        db.close()
        
        del ks
        db = shelve.open( outFileName, 'r' )
        ks = db['store']
        db.close()

        self.failUnless( len(ks.streamESD()) == 3 )
        self.failUnless( len(ks.streamAOD()) == 0 )
        self.failUnless( len(ks.transient()) == 3 )
        ## MacOSX silently appends the .db suffix to shelve files. I haven't found a
        ## mechanism for determining the actual filename, which is why I've added the
        ## MacOSX-specific hack.
        from sys import platform
        if platform != 'darwin' :
            os.remove( outFileName )
        else:
            os.remove( outFileName+'.db')