CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Attributes
Config.TestModuleCommand Class Reference
Inheritance diagram for Config.TestModuleCommand:

Public Member Functions

def setUp
 
def testCloneSequence
 
def testExamples
 
def testFreeze
 
def testGlobalReplace
 
def testImplicitSchedule
 
def testModifier
 
def testOverride
 
def testParameterizable
 
def testPath
 
def testPrefers
 
def testProcessDumpPython
 
def testProcessExtend
 
def testProcessInsertion
 
def testPrune
 
def testSchedule
 
def testSecSource
 
def testSequence
 
def testSequence2
 
def testSubProcess
 
def testTypedParameterizable
 
def testUsing
 

Static Public Attributes

tuple d = p.dumpPython()
 
tuple p = Process("test")
 
tuple s = Sequence(p.a)
 

Detailed Description

Definition at line 1132 of file Config.py.

Member Function Documentation

def Config.TestModuleCommand.setUp (   self)
Nothing to do 

Definition at line 1133 of file Config.py.

1134  def setUp(self):
1135  """Nothing to do """
None
def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 1428 of file Config.py.

1429  def testCloneSequence(self):
1430  p = Process("test")
1431  a = EDAnalyzer("MyAnalyzer")
1432  p.a = a
1433  a.setLabel("a")
1434  b = EDAnalyzer("YOurAnalyzer")
1435  p.b = b
1436  b.setLabel("b")
1437  path = Path(a * b)
1438  p.path = Path(p.a*p.b)
1439  lookuptable = {id(a): p.a, id(b): p.b}
1440  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1441  #lookuptable = p._cloneToObjectDict
1442  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1443  self.assertEqual(str(path),str(p.path))
def Config.TestModuleCommand.testExamples (   self)

Definition at line 1561 of file Config.py.

References Types.untracked.

1562  def testExamples(self):
1563  p = Process("Test")
1564  p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root")))
1565  p.foos = EDProducer("FooProducer")
1566  p.bars = EDProducer("BarProducer", foos=InputTag("foos"))
1567  p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root")))
1568  p.bars.foos = 'Foosball'
1569  self.assertEqual(p.bars.foos, InputTag('Foosball'))
1570  p.p = Path(p.foos*p.bars)
1571  p.e = EndPath(p.out)
1572  p.add_(Service("MessageLogger"))
tuple untracked
Definition: Types.py:27
def Config.TestModuleCommand.testFreeze (   self)

Definition at line 1627 of file Config.py.

1628  def testFreeze(self):
1629  process = Process("Freeze")
1630  m = EDProducer("M", p=PSet(i = int32(1)))
1631  m.p.i = 2
1632  process.m = m
1633  # should be frozen
1634  #self.assertRaises(ValueError, setattr, m.p, 'i', 3)
1635  #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1)))
1636  #self.assertRaises(ValueError, setattr, m.p, 'j', 1)
1637  #self.assertRaises(ValueError, setattr, m, 'j', 1)
1638  # But OK to change through the process
1639  process.m.p.i = 4
1640  self.assertEqual(process.m.p.i.value(), 4)
1641  process.m.p = PSet(j=int32(1))
1642  # should work to clone it, though
1643  m2 = m.clone(p = PSet(i = int32(5)), j = int32(8))
1644  m2.p.i = 6
m2.j = 8
def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 1371 of file Config.py.

1372  def testGlobalReplace(self):
1373  p = Process('test')
1374  p.a = EDAnalyzer("MyAnalyzer")
1375  p.b = EDAnalyzer("YourAnalyzer")
1376  p.c = EDAnalyzer("OurAnalyzer")
1377  p.s = Sequence(p.a*p.b)
1378  p.p = Path(p.c+p.s+p.a)
1379  new = EDAnalyzer("NewAnalyzer")
1380  p.globalReplace("a",new)
def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 1498 of file Config.py.

1499  def testImplicitSchedule(self):
1500  p = Process("test")
1501  p.a = EDAnalyzer("MyAnalyzer")
1502  p.b = EDAnalyzer("YourAnalyzer")
1503  p.c = EDAnalyzer("OurAnalyzer")
1504  p.path1 = Path(p.a)
1505  p.path2 = Path(p.b)
1506  self.assert_(p.schedule is None)
1507  pths = p.paths
1508  keys = pths.keys()
1509  self.assertEqual(pths[keys[0]],p.path1)
1510  self.assertEqual(pths[keys[1]],p.path2)
1511  p.prune()
1512  self.assert_(hasattr(p, 'a'))
1513  self.assert_(hasattr(p, 'b'))
1514  self.assert_(not hasattr(p, 'c'))
1515  self.assert_(hasattr(p, 'path1'))
1516  self.assert_(hasattr(p, 'path2'))
1517 
1518 
1519  p = Process("test")
1520  p.a = EDAnalyzer("MyAnalyzer")
1521  p.b = EDAnalyzer("YourAnalyzer")
1522  p.c = EDAnalyzer("OurAnalyzer")
1523  p.path2 = Path(p.b)
1524  p.path1 = Path(p.a)
1525  self.assert_(p.schedule is None)
1526  pths = p.paths
1527  keys = pths.keys()
1528  self.assertEqual(pths[keys[1]],p.path1)
1529  self.assertEqual(pths[keys[0]],p.path2)
1530 
def Config.TestModuleCommand.testModifier (   self)

Definition at line 1757 of file Config.py.

1758  def testModifier(self):
1759  m1 = Modifier()
1760  p = Process("test")
1761  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1762  def _mod_fred(obj):
1763  obj.fred = 2
1764  m1.toModify(p.a,_mod_fred)
1765  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1766  m1.toModify(p.b, wilma = 2)
1767  self.assertEqual(p.a.fred.value(),1)
1768  self.assertEqual(p.b.wilma.value(),1)
1769  m1.modify(p)
1770  self.assertEqual(p.a.fred.value(),2)
1771  self.assertEqual(p.b.wilma.value(),2)
1772  #check that items not attached to process are unchanged
1773  m1 = Modifier()
1774  p = Process("test")
1775  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1776  m1.toModify(p.a,_mod_fred)
1777  b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1778  m1.toModify(b, wilma = 2)
1779  self.assertEqual(p.a.fred.value(),1)
1780  self.assertEqual(b.wilma.value(),1)
1781  m1.modify(p)
1782  self.assertEqual(p.a.fred.value(),2)
1783  self.assertEqual(b.wilma.value(),1)
1784  #make sure chains of modifiers work
1785  m1 = Modifier()
1786  m2 = Modifier()
1787  m2.toModifyProcess(m1)
1788  p = Process("test")
1789  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1790  m1.toModify(p.a,_mod_fred)
1791  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1792  m1.toModify(p.b, wilma = 2)
1793  m2.toModify(p.b, wilma = 3)
1794  m2.modify(p)
1795  self.assertEqual(p.a.fred.value(),2)
1796  self.assertEqual(p.b.wilma.value(),3)
1797 
unittest.main()
def Config.TestModuleCommand.testOverride (   self)

Definition at line 1538 of file Config.py.

1539  def testOverride(self):
1540  p = Process('test')
1541  a = EDProducer("A", a1=int32(0))
1542  self.assert_(not a.isModified())
1543  a.a1 = 1
1544  self.assert_(a.isModified())
1545  p.a = a
1546  self.assertEqual(p.a.a1.value(), 1)
1547  # try adding an unmodified module.
1548  # should accept it
1549  p.a = EDProducer("A", a1=int32(2))
1550  self.assertEqual(p.a.a1.value(), 2)
1551  # try adding a modified module. Should throw
1552  # no longer, since the same (modified) say, geometry
1553  # could come from more than one cff
1554  b = EDProducer("A", a1=int32(3))
1555  b.a1 = 4
1556  #self.assertRaises(RuntimeError, setattr, *(p,'a',b))
1557  ps1 = PSet(a = int32(1))
1558  ps2 = PSet(a = int32(2))
1559  self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2)
1560  self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
def Config.TestModuleCommand.testParameterizable (   self)

Definition at line 1136 of file Config.py.

1137  def testParameterizable(self):
1138  p = _Parameterizable()
1139  self.assertEqual(len(p.parameterNames_()),0)
1140  p.a = int32(1)
1141  self.assert_('a' in p.parameterNames_())
1142  self.assertEqual(p.a.value(), 1)
1143  p.a = 10
1144  self.assertEqual(p.a.value(), 10)
1145  p.a = untracked(int32(1))
1146  self.assertEqual(p.a.value(), 1)
1147  self.failIf(p.a.isTracked())
1148  p.a = untracked.int32(1)
1149  self.assertEqual(p.a.value(), 1)
1150  self.failIf(p.a.isTracked())
1151  p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0)))
1152  self.assertEqual(p.foo.value(), 10)
1153  self.assertEqual(p.bar.value(),1.0)
1154  self.failIf(p.bar.isTracked())
1155  self.assertRaises(TypeError,setattr,(p,'c',1))
1156  p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0))))
1157  self.assertEqual(p.a.foo.value(),10)
1158  self.assertEqual(p.a.bar.value(),1.0)
1159  p.b = untracked(PSet(fii = int32(1)))
1160  self.assertEqual(p.b.fii.value(),1)
1161  self.failIf(p.b.isTracked())
1162  #test the fact that values can be shared
1163  v = int32(10)
1164  p=_Parameterizable(a=v)
1165  v.setValue(11)
1166  self.assertEqual(p.a.value(),11)
1167  p.a = 12
1168  self.assertEqual(p.a.value(),12)
self.assertEqual(v.value(),12)
tuple untracked
Definition: Types.py:27
def Config.TestModuleCommand.testPath (   self)

Definition at line 1406 of file Config.py.

1407  def testPath(self):
1408  p = Process("test")
1409  p.a = EDAnalyzer("MyAnalyzer")
1410  p.b = EDAnalyzer("YourAnalyzer")
1411  p.c = EDAnalyzer("OurAnalyzer")
1412  path = Path(p.a)
1413  path *= p.b
1414  path += p.c
1415  self.assertEqual(str(path),'a+b+c')
1416  path = Path(p.a*p.b+p.c)
1417  self.assertEqual(str(path),'a+b+c')
1418 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
1419 # self.assertEqual(str(path),'((a*b)+c)')
1420  path = Path(p.a+ p.b*p.c)
1421  self.assertEqual(str(path),'a+b+c')
1422  path = Path(p.a*(p.b+p.c))
1423  self.assertEqual(str(path),'a+b+c')
1424  path = Path(p.a*(p.b+~p.c))
1425  self.assertEqual(str(path),'a+b+~c')
1426  p.es = ESProducer("AnESProducer")
1427  self.assertRaises(TypeError,Path,p.es)
def Config.TestModuleCommand.testPrefers (   self)

Definition at line 1573 of file Config.py.

1574  def testPrefers(self):
1575  p = Process("Test")
1576  p.add_(ESSource("ForceSource"))
1577  p.juicer = ESProducer("JuicerProducer")
1578  p.prefer("ForceSource")
1579  p.prefer("juicer")
1580  self.assertEqual(p.dumpConfig(),
1581 """process Test = {
1582  es_module juicer = JuicerProducer {
1583  }
1584  es_source = ForceSource {
1585  }
1586  es_prefer = ForceSource {
1587  }
1588  es_prefer juicer = JuicerProducer {
1589  }
1590 }
1591 """)
1592  p.prefer("juicer",fooRcd=vstring("Foo"))
1593  self.assertEqual(p.dumpConfig(),
1594 """process Test = {
1595  es_module juicer = JuicerProducer {
1596  }
1597  es_source = ForceSource {
1598  }
1599  es_prefer = ForceSource {
1600  }
1601  es_prefer juicer = JuicerProducer {
1602  vstring fooRcd = {
1603  'Foo'
1604  }
1605 
1606  }
1607 }
1608 """)
1609  self.assertEqual(p.dumpPython(),
1610 """import FWCore.ParameterSet.Config as cms
1611 
1612 process = cms.Process("Test")
1613 
1614 process.juicer = cms.ESProducer("JuicerProducer")
1615 
1616 
1617 process.ForceSource = cms.ESSource("ForceSource")
1618 
1619 
1620 process.prefer("ForceSource")
1621 
1622 process.prefer("juicer",
1623  fooRcd = cms.vstring('Foo')
1624 )
1625 
1626 """)
def Config.TestModuleCommand.testProcessDumpPython (   self)

Definition at line 1271 of file Config.py.

1272  def testProcessDumpPython(self):
1273  p = Process("test")
1274  p.a = EDAnalyzer("MyAnalyzer")
1275  p.p = Path(p.a)
1276  p.s = Sequence(p.a)
1277  p.r = Sequence(p.s)
1278  p.p2 = Path(p.s)
1279  p.schedule = Schedule(p.p2,p.p)
1280  d=p.dumpPython()
1281  self.assertEqual(d,
1282 """import FWCore.ParameterSet.Config as cms
1283 
1284 process = cms.Process("test")
1285 
1286 process.a = cms.EDAnalyzer("MyAnalyzer")
1287 
1288 
1289 process.s = cms.Sequence(process.a)
1290 
1291 
1292 process.r = cms.Sequence(process.s)
1293 
1294 
1295 process.p = cms.Path(process.a)
1296 
1297 
1298 process.p2 = cms.Path(process.s)
1299 
1300 
1301 process.schedule = cms.Schedule(*[ process.p2, process.p ])
1302 """)
1303  #Reverse order of 'r' and 's'
1304  p = Process("test")
1305  p.a = EDAnalyzer("MyAnalyzer")
1306  p.p = Path(p.a)
1307  p.r = Sequence(p.a)
1308  p.s = Sequence(p.r)
1309  p.p2 = Path(p.r)
1310  p.schedule = Schedule(p.p2,p.p)
1311  p.b = EDAnalyzer("YourAnalyzer")
1312  d=p.dumpPython()
1313  self.assertEqual(d,
1314 """import FWCore.ParameterSet.Config as cms
1315 
1316 process = cms.Process("test")
1317 
1318 process.a = cms.EDAnalyzer("MyAnalyzer")
1319 
1320 
1321 process.b = cms.EDAnalyzer("YourAnalyzer")
1322 
1323 
1324 process.r = cms.Sequence(process.a)
1325 
1326 
1327 process.s = cms.Sequence(process.r)
1328 
1329 
1330 process.p = cms.Path(process.a)
1331 
1332 
1333 process.p2 = cms.Path(process.r)
1334 
1335 
1336 process.schedule = cms.Schedule(*[ process.p2, process.p ])
""")
def Config.TestModuleCommand.testProcessExtend (   self)

Definition at line 1201 of file Config.py.

References python.multivaluedict.__init__(), and dbtoconf.object.

1202  def testProcessExtend(self):
1203  class FromArg(object):
1204  def __init__(self,*arg,**args):
1205  for name in args.iterkeys():
1206  self.__dict__[name]=args[name]
1207 
1208  a=EDAnalyzer("MyAnalyzer")
1209  t=EDAnalyzer("MyAnalyzer")
1210  t.setLabel("foo")
1211  s1 = Sequence(a)
1212  s2 = Sequence(s1)
1213  s3 = Sequence(s2)
1214  d = FromArg(
1215  a=a,
1216  b=Service("Full"),
1217  c=Path(a),
1218  d=s2,
1219  e=s1,
1220  f=s3,
1221  g=Sequence(s1+s2+s3)
1222  )
1223  p = Process("Test")
1224  p.extend(d)
1225  self.assertEqual(p.a.type_(),"MyAnalyzer")
1226  self.assertEqual(p.a.label_(),"a")
1227  self.assertRaises(AttributeError,getattr,p,'b')
1228  self.assertEqual(p.Full.type_(),"Full")
1229  self.assertEqual(str(p.c),'a')
1230  self.assertEqual(str(p.d),'a')
1231 
1232  z1 = FromArg(
1233  a=a,
1234  b=Service("Full"),
1235  c=Path(a),
1236  d=s2,
1237  e=s1,
1238  f=s3,
1239  s4=s3,
1240  g=Sequence(s1+s2+s3)
1241  )
1242 
1243  p1 = Process("Test")
1244  #p1.extend(z1)
1245  self.assertRaises(ValueError, p1.extend, z1)
1246 
1247  z2 = FromArg(
1248  a=a,
1249  b=Service("Full"),
1250  c=Path(a),
1251  d=s2,
1252  e=s1,
1253  f=s3,
1254  aaa=copy.deepcopy(a),
1255  s4=copy.deepcopy(s3),
1256  g=Sequence(s1+s2+s3),
1257  t=t
1258  )
1259  p2 = Process("Test")
1260  p2.extend(z2)
1261  #self.assertRaises(ValueError, p2.extend, z2)
1262  self.assertEqual(p2.s4.label_(),"s4")
1263  #p2.s4.setLabel("foo")
1264  self.assertRaises(ValueError, p2.s4.setLabel, "foo")
1265  p2.s4.setLabel("s4")
1266  p2.s4.setLabel(None)
1267  p2.s4.setLabel("foo")
1268  p2._Process__setObjectLabel(p2.s4, "foo")
1269  p2._Process__setObjectLabel(p2.s4, None)
1270  p2._Process__setObjectLabel(p2.s4, "bar")
list object
Definition: dbtoconf.py:77
def Config.TestModuleCommand.testProcessInsertion (   self)

Definition at line 1176 of file Config.py.

1177  def testProcessInsertion(self):
1178  p = Process("test")
1179  p.a = EDAnalyzer("MyAnalyzer")
1180  self.assert_( 'a' in p.analyzers_() )
1181  self.assert_( 'a' in p.analyzers)
1182  p.add_(Service("MessageLogger"))
1183  self.assert_('MessageLogger' in p.services_())
1184  self.assertEqual(p.MessageLogger.type_(), "MessageLogger")
1185  p.Tracer = Service("Tracer")
1186  self.assert_('Tracer' in p.services_())
1187  self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
1188  self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger")))
1189  self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource")))
1190  p.out = OutputModule("Outer")
1191  self.assertEqual(p.out.type_(), 'Outer')
1192  self.assert_( 'out' in p.outputModules_() )
1193 
1194  p.geom = ESSource("GeomProd")
1195  self.assert_('geom' in p.es_sources_())
1196  p.add_(ESSource("ConfigDB"))
1197  self.assert_('ConfigDB' in p.es_sources_())
1198 
1199  p.aliasfoo1 = EDAlias(foo1 = VPSet(PSet(type = string("Foo1"))))
1200  self.assert_('aliasfoo1' in p.aliases_())
def Config.TestModuleCommand.testPrune (   self)

Definition at line 1684 of file Config.py.

1685  def testPrune(self):
1686  p = Process("test")
1687  p.a = EDAnalyzer("MyAnalyzer")
1688  p.b = EDAnalyzer("YourAnalyzer")
1689  p.c = EDAnalyzer("OurAnalyzer")
1690  p.d = EDAnalyzer("OurAnalyzer")
1691  p.s = Sequence(p.d)
1692  p.path1 = Path(p.a)
1693  p.path2 = Path(p.b)
1694  self.assert_(p.schedule is None)
1695  pths = p.paths
1696  keys = pths.keys()
1697  self.assertEqual(pths[keys[0]],p.path1)
1698  self.assertEqual(pths[keys[1]],p.path2)
1699  p.pset1 = PSet(parA = string("pset1"))
1700  p.pset2 = untracked.PSet(parA = string("pset2"))
1701  p.vpset1 = VPSet()
1702  p.vpset2 = untracked.VPSet()
1703  p.prune()
1704  self.assert_(hasattr(p, 'a'))
1705  self.assert_(hasattr(p, 'b'))
1706  self.assert_(not hasattr(p, 'c'))
1707  self.assert_(not hasattr(p, 'd'))
1708  self.assert_(not hasattr(p, 's'))
1709  self.assert_(hasattr(p, 'path1'))
1710  self.assert_(hasattr(p, 'path2'))
1711  self.assert_(not hasattr(p, 'pset1'))
1712  self.assert_(hasattr(p, 'pset2'))
1713  self.assert_(not hasattr(p, 'vpset1'))
1714  self.assert_(not hasattr(p, 'vpset2'))
1715 
1716  p = Process("test")
1717  p.a = EDAnalyzer("MyAnalyzer")
1718  p.b = EDAnalyzer("YourAnalyzer")
1719  p.c = EDAnalyzer("OurAnalyzer")
1720  p.d = EDAnalyzer("OurAnalyzer")
1721  p.e = EDAnalyzer("OurAnalyzer")
1722  p.s = Sequence(p.d)
1723  p.s2 = Sequence(p.b)
1724  p.s3 = Sequence(p.e)
1725  p.path1 = Path(p.a)
1726  p.path2 = Path(p.b)
1727  p.path3 = Path(p.b+p.s2)
1728  p.path4 = Path(p.b+p.s3)
1729  p.schedule = Schedule(p.path1,p.path2,p.path3)
1730  pths = p.paths
1731  keys = pths.keys()
1732  self.assertEqual(pths[keys[0]],p.path1)
1733  self.assertEqual(pths[keys[1]],p.path2)
1734  p.prune()
1735  self.assert_(hasattr(p, 'a'))
1736  self.assert_(hasattr(p, 'b'))
1737  self.assert_(not hasattr(p, 'c'))
1738  self.assert_(not hasattr(p, 'd'))
1739  self.assert_(not hasattr(p, 'e'))
1740  self.assert_(not hasattr(p, 's'))
1741  self.assert_(hasattr(p, 's2'))
1742  self.assert_(not hasattr(p, 's3'))
1743  self.assert_(hasattr(p, 'path1'))
1744  self.assert_(hasattr(p, 'path2'))
1745  self.assert_(hasattr(p, 'path3'))
1746  self.assert_(not hasattr(p, 'path4'))
1747  #test SequencePlaceholder
1748  p = Process("test")
1749  p.a = EDAnalyzer("MyAnalyzer")
1750  p.b = EDAnalyzer("YourAnalyzer")
1751  p.s = Sequence(SequencePlaceholder("a")+p.b)
1752  p.pth = Path(p.s)
1753  p.prune()
1754  self.assert_(hasattr(p, 'a'))
1755  self.assert_(hasattr(p, 'b'))
1756  self.assert_(hasattr(p, 's'))
self.assert_(hasattr(p, 'pth'))
def Config.TestModuleCommand.testSchedule (   self)

Definition at line 1444 of file Config.py.

1445  def testSchedule(self):
1446  p = Process("test")
1447  p.a = EDAnalyzer("MyAnalyzer")
1448  p.b = EDAnalyzer("YourAnalyzer")
1449  p.c = EDAnalyzer("OurAnalyzer")
1450  p.d = EDAnalyzer("OurAnalyzer")
1451  p.path1 = Path(p.a)
1452  p.path2 = Path(p.b)
1453  p.path3 = Path(p.d)
1454 
1455  s = Schedule(p.path1,p.path2)
1456  self.assertEqual(s[0],p.path1)
1457  self.assertEqual(s[1],p.path2)
1458  p.schedule = s
1459  self.assert_('b' in p.schedule.moduleNames())
1460  self.assert_(hasattr(p, 'b'))
1461  self.assert_(hasattr(p, 'c'))
1462  self.assert_(hasattr(p, 'd'))
1463  self.assert_(hasattr(p, 'path1'))
1464  self.assert_(hasattr(p, 'path2'))
1465  self.assert_(hasattr(p, 'path3'))
1466  p.prune()
1467  self.assert_('b' in p.schedule.moduleNames())
1468  self.assert_(hasattr(p, 'b'))
1469  self.assert_(not hasattr(p, 'c'))
1470  self.assert_(not hasattr(p, 'd'))
1471  self.assert_(hasattr(p, 'path1'))
1472  self.assert_(hasattr(p, 'path2'))
1473  self.assert_(not hasattr(p, 'path3'))
1474 
1475  #adding a path not attached to the Process should cause an exception
1476  p = Process("test")
1477  p.a = EDAnalyzer("MyAnalyzer")
1478  path1 = Path(p.a)
1479  s = Schedule(path1)
1480  self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) )
1481 
1482  #make sure anonymous sequences work
1483  p = Process("test")
1484  p.a = EDAnalyzer("MyAnalyzer")
1485  p.b = EDAnalyzer("MyOtherAnalyzer")
1486  p.c = EDProducer("MyProd")
1487  path1 = Path(p.c*Sequence(p.a+p.b))
1488  s = Schedule(path1)
1489  self.assert_('a' in s.moduleNames())
1490  self.assert_('b' in s.moduleNames())
1491  self.assert_('c' in s.moduleNames())
1492  p.path1 = path1
1493  p.schedule = s
1494  p.prune()
1495  self.assert_('a' in s.moduleNames())
1496  self.assert_('b' in s.moduleNames())
1497  self.assert_('c' in s.moduleNames())
def Config.TestModuleCommand.testSecSource (   self)

Definition at line 1366 of file Config.py.

References python.rootplot.root2matplotlib.replace().

1367  def testSecSource(self):
1368  p = Process('test')
1369  p.a = SecSource("MySecSource")
1370  self.assertEqual(p.dumpPython().replace('\n',''),'import FWCore.ParameterSet.Config as cmsprocess = cms.Process("test")process.a = cms.SecSource("MySecSource")')
def Config.TestModuleCommand.testSequence (   self)

Definition at line 1381 of file Config.py.

1382  def testSequence(self):
1383  p = Process('test')
1384  p.a = EDAnalyzer("MyAnalyzer")
1385  p.b = EDAnalyzer("YourAnalyzer")
1386  p.c = EDAnalyzer("OurAnalyzer")
1387  p.s = Sequence(p.a*p.b)
1388  self.assertEqual(str(p.s),'a+b')
1389  self.assertEqual(p.s.label_(),'s')
1390  path = Path(p.c+p.s)
1391  self.assertEqual(str(path),'c+a+b')
1392  p._validateSequence(path, 'p1')
1393  notInProcess = EDAnalyzer('NotInProcess')
1394  p2 = Path(p.c+p.s*notInProcess)
1395  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 1396 of file Config.py.

1397  def testSequence2(self):
1398  p = Process('test')
1399  p.a = EDAnalyzer("MyAnalyzer")
1400  p.b = EDAnalyzer("YourAnalyzer")
1401  p.c = EDAnalyzer("OurAnalyzer")
1402  testseq = Sequence(p.a*p.b)
1403  p.s = testseq
1404  #p.y = testseq
1405  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 1645 of file Config.py.

References cond.hash.

1646  def testSubProcess(self):
1647  process = Process("Parent")
1648  subProcess = Process("Child")
1649  subProcess.a = EDProducer("A")
1650  subProcess.p = Path(subProcess.a)
1651  subProcess.add_(Service("Foo"))
1652  process.add_( SubProcess(subProcess) )
1653  d = process.dumpPython()
1654  equalD ="""import FWCore.ParameterSet.Config as cms
1655 
1656 process = cms.Process("Parent")
1657 
1658 parentProcess = process
1659 import FWCore.ParameterSet.Config as cms
1660 
1661 process = cms.Process("Child")
1662 
1663 process.a = cms.EDProducer("A")
1664 
1665 
1666 process.p = cms.Path(process.a)
1667 
1668 
1669 process.Foo = cms.Service("Foo")
1670 
1671 
1672 childProcess = process
1673 process = parentProcess
1674 process.subProcess = cms.SubProcess( process = childProcess, SelectEvents = cms.untracked.PSet(
1675 
1676 ), outputCommands = cms.untracked.vstring())
1677 """
1678  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcess)))
1679  self.assertEqual(d,equalD)
1680  p = TestMakePSet()
1681  process.subProcess.insertInto(p,"dummy")
1682  self.assertEqual((True,['a']),p.values["@sub_process"][1].values["process"][1].values['@all_modules'])
1683  self.assertEqual((True,['p']),p.values["@sub_process"][1].values["process"][1].values['@paths'])
self.assertEqual({'@service_type':(True,'Foo')}, p.values["@sub_process"][1].values["process"][1].values["services"][1][0].values)
def Config.TestModuleCommand.testTypedParameterizable (   self)

Definition at line 1169 of file Config.py.

1170  def testTypedParameterizable(self):
1171  p = _TypedParameterizable("blah", b=int32(1))
1172  #see if copy works deeply
1173  other = p.copy()
1174  other.b = 2
1175  self.assertNotEqual(p.b,other.b)
def Config.TestModuleCommand.testUsing (   self)

Definition at line 1531 of file Config.py.

1532  def testUsing(self):
1533  p = Process('test')
1534  p.block = PSet(a = int32(1))
1535  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
1536  self.assertEqual(p.modu.a.value(),1)
1537  self.assertEqual(p.modu.b.value(),2)

Member Data Documentation

tuple Config.TestModuleCommand.d = p.dumpPython()
static

Definition at line 1345 of file Config.py.

tuple Config.TestModuleCommand.p = Process("test")
static

Definition at line 1338 of file Config.py.

tuple Config.TestModuleCommand.s = Sequence(p.a)
static

Definition at line 1341 of file Config.py.