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 testRefToPSet
 
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 1155 of file Config.py.

Member Function Documentation

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

Definition at line 1156 of file Config.py.

1157  def setUp(self):
1158  """Nothing to do """
None
def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 1451 of file Config.py.

1452  def testCloneSequence(self):
1453  p = Process("test")
1454  a = EDAnalyzer("MyAnalyzer")
1455  p.a = a
1456  a.setLabel("a")
1457  b = EDAnalyzer("YOurAnalyzer")
1458  p.b = b
1459  b.setLabel("b")
1460  path = Path(a * b)
1461  p.path = Path(p.a*p.b)
1462  lookuptable = {id(a): p.a, id(b): p.b}
1463  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1464  #lookuptable = p._cloneToObjectDict
1465  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1466  self.assertEqual(str(path),str(p.path))
def Config.TestModuleCommand.testExamples (   self)

Definition at line 1584 of file Config.py.

References Types.untracked.

1585  def testExamples(self):
1586  p = Process("Test")
1587  p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root")))
1588  p.foos = EDProducer("FooProducer")
1589  p.bars = EDProducer("BarProducer", foos=InputTag("foos"))
1590  p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root")))
1591  p.bars.foos = 'Foosball'
1592  self.assertEqual(p.bars.foos, InputTag('Foosball'))
1593  p.p = Path(p.foos*p.bars)
1594  p.e = EndPath(p.out)
1595  p.add_(Service("MessageLogger"))
tuple untracked
Definition: Types.py:27
def Config.TestModuleCommand.testFreeze (   self)

Definition at line 1650 of file Config.py.

1651  def testFreeze(self):
1652  process = Process("Freeze")
1653  m = EDProducer("M", p=PSet(i = int32(1)))
1654  m.p.i = 2
1655  process.m = m
1656  # should be frozen
1657  #self.assertRaises(ValueError, setattr, m.p, 'i', 3)
1658  #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1)))
1659  #self.assertRaises(ValueError, setattr, m.p, 'j', 1)
1660  #self.assertRaises(ValueError, setattr, m, 'j', 1)
1661  # But OK to change through the process
1662  process.m.p.i = 4
1663  self.assertEqual(process.m.p.i.value(), 4)
1664  process.m.p = PSet(j=int32(1))
1665  # should work to clone it, though
1666  m2 = m.clone(p = PSet(i = int32(5)), j = int32(8))
1667  m2.p.i = 6
m2.j = 8
def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 1394 of file Config.py.

1395  def testGlobalReplace(self):
1396  p = Process('test')
1397  p.a = EDAnalyzer("MyAnalyzer")
1398  p.b = EDAnalyzer("YourAnalyzer")
1399  p.c = EDAnalyzer("OurAnalyzer")
1400  p.s = Sequence(p.a*p.b)
1401  p.p = Path(p.c+p.s+p.a)
1402  new = EDAnalyzer("NewAnalyzer")
1403  p.globalReplace("a",new)
def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 1521 of file Config.py.

1522  def testImplicitSchedule(self):
1523  p = Process("test")
1524  p.a = EDAnalyzer("MyAnalyzer")
1525  p.b = EDAnalyzer("YourAnalyzer")
1526  p.c = EDAnalyzer("OurAnalyzer")
1527  p.path1 = Path(p.a)
1528  p.path2 = Path(p.b)
1529  self.assert_(p.schedule is None)
1530  pths = p.paths
1531  keys = pths.keys()
1532  self.assertEqual(pths[keys[0]],p.path1)
1533  self.assertEqual(pths[keys[1]],p.path2)
1534  p.prune()
1535  self.assert_(hasattr(p, 'a'))
1536  self.assert_(hasattr(p, 'b'))
1537  self.assert_(not hasattr(p, 'c'))
1538  self.assert_(hasattr(p, 'path1'))
1539  self.assert_(hasattr(p, 'path2'))
1540 
1541 
1542  p = Process("test")
1543  p.a = EDAnalyzer("MyAnalyzer")
1544  p.b = EDAnalyzer("YourAnalyzer")
1545  p.c = EDAnalyzer("OurAnalyzer")
1546  p.path2 = Path(p.b)
1547  p.path1 = Path(p.a)
1548  self.assert_(p.schedule is None)
1549  pths = p.paths
1550  keys = pths.keys()
1551  self.assertEqual(pths[keys[1]],p.path1)
1552  self.assertEqual(pths[keys[0]],p.path2)
1553 
def Config.TestModuleCommand.testModifier (   self)

Definition at line 1796 of file Config.py.

1797  def testModifier(self):
1798  m1 = Modifier()
1799  p = Process("test")
1800  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1801  def _mod_fred(obj):
1802  obj.fred = 2
1803  m1.toModify(p.a,_mod_fred)
1804  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1805  m1.toModify(p.b, wilma = 2)
1806  self.assertEqual(p.a.fred.value(),1)
1807  self.assertEqual(p.b.wilma.value(),1)
1808  m1.modify(p)
1809  self.assertEqual(p.a.fred.value(),2)
1810  self.assertEqual(p.b.wilma.value(),2)
1811  #check that items not attached to process are unchanged
1812  m1 = Modifier()
1813  p = Process("test")
1814  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1815  m1.toModify(p.a,_mod_fred)
1816  b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1817  m1.toModify(b, wilma = 2)
1818  self.assertEqual(p.a.fred.value(),1)
1819  self.assertEqual(b.wilma.value(),1)
1820  m1.modify(p)
1821  self.assertEqual(p.a.fred.value(),2)
1822  self.assertEqual(b.wilma.value(),1)
1823  #make sure chains of modifiers work
1824  m1 = Modifier()
1825  m2 = Modifier()
1826  m2.toModifyProcess(m1)
1827  p = Process("test")
1828  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1829  m1.toModify(p.a,_mod_fred)
1830  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1831  m1.toModify(p.b, wilma = 2)
1832  m2.toModify(p.b, wilma = 3)
1833  m2.modify(p)
1834  self.assertEqual(p.a.fred.value(),2)
1835  self.assertEqual(p.b.wilma.value(),3)
1836 
unittest.main()
def Config.TestModuleCommand.testOverride (   self)

Definition at line 1561 of file Config.py.

1562  def testOverride(self):
1563  p = Process('test')
1564  a = EDProducer("A", a1=int32(0))
1565  self.assert_(not a.isModified())
1566  a.a1 = 1
1567  self.assert_(a.isModified())
1568  p.a = a
1569  self.assertEqual(p.a.a1.value(), 1)
1570  # try adding an unmodified module.
1571  # should accept it
1572  p.a = EDProducer("A", a1=int32(2))
1573  self.assertEqual(p.a.a1.value(), 2)
1574  # try adding a modified module. Should throw
1575  # no longer, since the same (modified) say, geometry
1576  # could come from more than one cff
1577  b = EDProducer("A", a1=int32(3))
1578  b.a1 = 4
1579  #self.assertRaises(RuntimeError, setattr, *(p,'a',b))
1580  ps1 = PSet(a = int32(1))
1581  ps2 = PSet(a = int32(2))
1582  self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2)
1583  self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
def Config.TestModuleCommand.testParameterizable (   self)

Definition at line 1159 of file Config.py.

1160  def testParameterizable(self):
1161  p = _Parameterizable()
1162  self.assertEqual(len(p.parameterNames_()),0)
1163  p.a = int32(1)
1164  self.assert_('a' in p.parameterNames_())
1165  self.assertEqual(p.a.value(), 1)
1166  p.a = 10
1167  self.assertEqual(p.a.value(), 10)
1168  p.a = untracked(int32(1))
1169  self.assertEqual(p.a.value(), 1)
1170  self.failIf(p.a.isTracked())
1171  p.a = untracked.int32(1)
1172  self.assertEqual(p.a.value(), 1)
1173  self.failIf(p.a.isTracked())
1174  p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0)))
1175  self.assertEqual(p.foo.value(), 10)
1176  self.assertEqual(p.bar.value(),1.0)
1177  self.failIf(p.bar.isTracked())
1178  self.assertRaises(TypeError,setattr,(p,'c',1))
1179  p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0))))
1180  self.assertEqual(p.a.foo.value(),10)
1181  self.assertEqual(p.a.bar.value(),1.0)
1182  p.b = untracked(PSet(fii = int32(1)))
1183  self.assertEqual(p.b.fii.value(),1)
1184  self.failIf(p.b.isTracked())
1185  #test the fact that values can be shared
1186  v = int32(10)
1187  p=_Parameterizable(a=v)
1188  v.setValue(11)
1189  self.assertEqual(p.a.value(),11)
1190  p.a = 12
1191  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 1429 of file Config.py.

1430  def testPath(self):
1431  p = Process("test")
1432  p.a = EDAnalyzer("MyAnalyzer")
1433  p.b = EDAnalyzer("YourAnalyzer")
1434  p.c = EDAnalyzer("OurAnalyzer")
1435  path = Path(p.a)
1436  path *= p.b
1437  path += p.c
1438  self.assertEqual(str(path),'a+b+c')
1439  path = Path(p.a*p.b+p.c)
1440  self.assertEqual(str(path),'a+b+c')
1441 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
1442 # self.assertEqual(str(path),'((a*b)+c)')
1443  path = Path(p.a+ p.b*p.c)
1444  self.assertEqual(str(path),'a+b+c')
1445  path = Path(p.a*(p.b+p.c))
1446  self.assertEqual(str(path),'a+b+c')
1447  path = Path(p.a*(p.b+~p.c))
1448  self.assertEqual(str(path),'a+b+~c')
1449  p.es = ESProducer("AnESProducer")
1450  self.assertRaises(TypeError,Path,p.es)
def Config.TestModuleCommand.testPrefers (   self)

Definition at line 1596 of file Config.py.

1597  def testPrefers(self):
1598  p = Process("Test")
1599  p.add_(ESSource("ForceSource"))
1600  p.juicer = ESProducer("JuicerProducer")
1601  p.prefer("ForceSource")
1602  p.prefer("juicer")
1603  self.assertEqual(p.dumpConfig(),
1604 """process Test = {
1605  es_module juicer = JuicerProducer {
1606  }
1607  es_source = ForceSource {
1608  }
1609  es_prefer = ForceSource {
1610  }
1611  es_prefer juicer = JuicerProducer {
1612  }
1613 }
1614 """)
1615  p.prefer("juicer",fooRcd=vstring("Foo"))
1616  self.assertEqual(p.dumpConfig(),
1617 """process Test = {
1618  es_module juicer = JuicerProducer {
1619  }
1620  es_source = ForceSource {
1621  }
1622  es_prefer = ForceSource {
1623  }
1624  es_prefer juicer = JuicerProducer {
1625  vstring fooRcd = {
1626  'Foo'
1627  }
1628 
1629  }
1630 }
1631 """)
1632  self.assertEqual(p.dumpPython(),
1633 """import FWCore.ParameterSet.Config as cms
1634 
1635 process = cms.Process("Test")
1636 
1637 process.juicer = cms.ESProducer("JuicerProducer")
1638 
1639 
1640 process.ForceSource = cms.ESSource("ForceSource")
1641 
1642 
1643 process.prefer("ForceSource")
1644 
1645 process.prefer("juicer",
1646  fooRcd = cms.vstring('Foo')
1647 )
1648 
1649 """)
def Config.TestModuleCommand.testProcessDumpPython (   self)

Definition at line 1294 of file Config.py.

1295  def testProcessDumpPython(self):
1296  p = Process("test")
1297  p.a = EDAnalyzer("MyAnalyzer")
1298  p.p = Path(p.a)
1299  p.s = Sequence(p.a)
1300  p.r = Sequence(p.s)
1301  p.p2 = Path(p.s)
1302  p.schedule = Schedule(p.p2,p.p)
1303  d=p.dumpPython()
1304  self.assertEqual(d,
1305 """import FWCore.ParameterSet.Config as cms
1306 
1307 process = cms.Process("test")
1308 
1309 process.a = cms.EDAnalyzer("MyAnalyzer")
1310 
1311 
1312 process.s = cms.Sequence(process.a)
1313 
1314 
1315 process.r = cms.Sequence(process.s)
1316 
1317 
1318 process.p = cms.Path(process.a)
1319 
1320 
1321 process.p2 = cms.Path(process.s)
1322 
1323 
1324 process.schedule = cms.Schedule(*[ process.p2, process.p ])
1325 """)
1326  #Reverse order of 'r' and 's'
1327  p = Process("test")
1328  p.a = EDAnalyzer("MyAnalyzer")
1329  p.p = Path(p.a)
1330  p.r = Sequence(p.a)
1331  p.s = Sequence(p.r)
1332  p.p2 = Path(p.r)
1333  p.schedule = Schedule(p.p2,p.p)
1334  p.b = EDAnalyzer("YourAnalyzer")
1335  d=p.dumpPython()
1336  self.assertEqual(d,
1337 """import FWCore.ParameterSet.Config as cms
1338 
1339 process = cms.Process("test")
1340 
1341 process.a = cms.EDAnalyzer("MyAnalyzer")
1342 
1343 
1344 process.b = cms.EDAnalyzer("YourAnalyzer")
1345 
1346 
1347 process.r = cms.Sequence(process.a)
1348 
1349 
1350 process.s = cms.Sequence(process.r)
1351 
1352 
1353 process.p = cms.Path(process.a)
1354 
1355 
1356 process.p2 = cms.Path(process.r)
1357 
1358 
1359 process.schedule = cms.Schedule(*[ process.p2, process.p ])
""")
def Config.TestModuleCommand.testProcessExtend (   self)

Definition at line 1224 of file Config.py.

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

1225  def testProcessExtend(self):
1226  class FromArg(object):
1227  def __init__(self,*arg,**args):
1228  for name in args.iterkeys():
1229  self.__dict__[name]=args[name]
1230 
1231  a=EDAnalyzer("MyAnalyzer")
1232  t=EDAnalyzer("MyAnalyzer")
1233  t.setLabel("foo")
1234  s1 = Sequence(a)
1235  s2 = Sequence(s1)
1236  s3 = Sequence(s2)
1237  d = FromArg(
1238  a=a,
1239  b=Service("Full"),
1240  c=Path(a),
1241  d=s2,
1242  e=s1,
1243  f=s3,
1244  g=Sequence(s1+s2+s3)
1245  )
1246  p = Process("Test")
1247  p.extend(d)
1248  self.assertEqual(p.a.type_(),"MyAnalyzer")
1249  self.assertEqual(p.a.label_(),"a")
1250  self.assertRaises(AttributeError,getattr,p,'b')
1251  self.assertEqual(p.Full.type_(),"Full")
1252  self.assertEqual(str(p.c),'a')
1253  self.assertEqual(str(p.d),'a')
1254 
1255  z1 = FromArg(
1256  a=a,
1257  b=Service("Full"),
1258  c=Path(a),
1259  d=s2,
1260  e=s1,
1261  f=s3,
1262  s4=s3,
1263  g=Sequence(s1+s2+s3)
1264  )
1265 
1266  p1 = Process("Test")
1267  #p1.extend(z1)
1268  self.assertRaises(ValueError, p1.extend, z1)
1269 
1270  z2 = FromArg(
1271  a=a,
1272  b=Service("Full"),
1273  c=Path(a),
1274  d=s2,
1275  e=s1,
1276  f=s3,
1277  aaa=copy.deepcopy(a),
1278  s4=copy.deepcopy(s3),
1279  g=Sequence(s1+s2+s3),
1280  t=t
1281  )
1282  p2 = Process("Test")
1283  p2.extend(z2)
1284  #self.assertRaises(ValueError, p2.extend, z2)
1285  self.assertEqual(p2.s4.label_(),"s4")
1286  #p2.s4.setLabel("foo")
1287  self.assertRaises(ValueError, p2.s4.setLabel, "foo")
1288  p2.s4.setLabel("s4")
1289  p2.s4.setLabel(None)
1290  p2.s4.setLabel("foo")
1291  p2._Process__setObjectLabel(p2.s4, "foo")
1292  p2._Process__setObjectLabel(p2.s4, None)
1293  p2._Process__setObjectLabel(p2.s4, "bar")
list object
Definition: dbtoconf.py:77
def Config.TestModuleCommand.testProcessInsertion (   self)

Definition at line 1199 of file Config.py.

1200  def testProcessInsertion(self):
1201  p = Process("test")
1202  p.a = EDAnalyzer("MyAnalyzer")
1203  self.assert_( 'a' in p.analyzers_() )
1204  self.assert_( 'a' in p.analyzers)
1205  p.add_(Service("MessageLogger"))
1206  self.assert_('MessageLogger' in p.services_())
1207  self.assertEqual(p.MessageLogger.type_(), "MessageLogger")
1208  p.Tracer = Service("Tracer")
1209  self.assert_('Tracer' in p.services_())
1210  self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
1211  self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger")))
1212  self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource")))
1213  p.out = OutputModule("Outer")
1214  self.assertEqual(p.out.type_(), 'Outer')
1215  self.assert_( 'out' in p.outputModules_() )
1216 
1217  p.geom = ESSource("GeomProd")
1218  self.assert_('geom' in p.es_sources_())
1219  p.add_(ESSource("ConfigDB"))
1220  self.assert_('ConfigDB' in p.es_sources_())
1221 
1222  p.aliasfoo1 = EDAlias(foo1 = VPSet(PSet(type = string("Foo1"))))
1223  self.assert_('aliasfoo1' in p.aliases_())
def Config.TestModuleCommand.testPrune (   self)

Definition at line 1723 of file Config.py.

1724  def testPrune(self):
1725  p = Process("test")
1726  p.a = EDAnalyzer("MyAnalyzer")
1727  p.b = EDAnalyzer("YourAnalyzer")
1728  p.c = EDAnalyzer("OurAnalyzer")
1729  p.d = EDAnalyzer("OurAnalyzer")
1730  p.s = Sequence(p.d)
1731  p.path1 = Path(p.a)
1732  p.path2 = Path(p.b)
1733  self.assert_(p.schedule is None)
1734  pths = p.paths
1735  keys = pths.keys()
1736  self.assertEqual(pths[keys[0]],p.path1)
1737  self.assertEqual(pths[keys[1]],p.path2)
1738  p.pset1 = PSet(parA = string("pset1"))
1739  p.pset2 = untracked.PSet(parA = string("pset2"))
1740  p.vpset1 = VPSet()
1741  p.vpset2 = untracked.VPSet()
1742  p.prune()
1743  self.assert_(hasattr(p, 'a'))
1744  self.assert_(hasattr(p, 'b'))
1745  self.assert_(not hasattr(p, 'c'))
1746  self.assert_(not hasattr(p, 'd'))
1747  self.assert_(not hasattr(p, 's'))
1748  self.assert_(hasattr(p, 'path1'))
1749  self.assert_(hasattr(p, 'path2'))
1750  self.assert_(not hasattr(p, 'pset1'))
1751  self.assert_(hasattr(p, 'pset2'))
1752  self.assert_(not hasattr(p, 'vpset1'))
1753  self.assert_(not hasattr(p, 'vpset2'))
1754 
1755  p = Process("test")
1756  p.a = EDAnalyzer("MyAnalyzer")
1757  p.b = EDAnalyzer("YourAnalyzer")
1758  p.c = EDAnalyzer("OurAnalyzer")
1759  p.d = EDAnalyzer("OurAnalyzer")
1760  p.e = EDAnalyzer("OurAnalyzer")
1761  p.s = Sequence(p.d)
1762  p.s2 = Sequence(p.b)
1763  p.s3 = Sequence(p.e)
1764  p.path1 = Path(p.a)
1765  p.path2 = Path(p.b)
1766  p.path3 = Path(p.b+p.s2)
1767  p.path4 = Path(p.b+p.s3)
1768  p.schedule = Schedule(p.path1,p.path2,p.path3)
1769  pths = p.paths
1770  keys = pths.keys()
1771  self.assertEqual(pths[keys[0]],p.path1)
1772  self.assertEqual(pths[keys[1]],p.path2)
1773  p.prune()
1774  self.assert_(hasattr(p, 'a'))
1775  self.assert_(hasattr(p, 'b'))
1776  self.assert_(not hasattr(p, 'c'))
1777  self.assert_(not hasattr(p, 'd'))
1778  self.assert_(not hasattr(p, 'e'))
1779  self.assert_(not hasattr(p, 's'))
1780  self.assert_(hasattr(p, 's2'))
1781  self.assert_(not hasattr(p, 's3'))
1782  self.assert_(hasattr(p, 'path1'))
1783  self.assert_(hasattr(p, 'path2'))
1784  self.assert_(hasattr(p, 'path3'))
1785  self.assert_(not hasattr(p, 'path4'))
1786  #test SequencePlaceholder
1787  p = Process("test")
1788  p.a = EDAnalyzer("MyAnalyzer")
1789  p.b = EDAnalyzer("YourAnalyzer")
1790  p.s = Sequence(SequencePlaceholder("a")+p.b)
1791  p.pth = Path(p.s)
1792  p.prune()
1793  self.assert_(hasattr(p, 'a'))
1794  self.assert_(hasattr(p, 'b'))
1795  self.assert_(hasattr(p, 's'))
self.assert_(hasattr(p, 'pth'))
def Config.TestModuleCommand.testRefToPSet (   self)

Definition at line 1707 of file Config.py.

1708  def testRefToPSet(self):
1709  proc = Process("test")
1710  proc.top = PSet(a = int32(1))
1711  proc.ref = PSet(refToPSet_ = string("top"))
1712  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
1713  proc.ref3 = PSet(refToPSet_ = string("ref"))
1714  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
1715  PSet(refToPSet_ = string("ref2")))
1716  p = TestMakePSet()
1717  proc.fillProcessDesc(p)
1718  self.assertEqual((True,1),p.values["ref"][1].values["a"])
1719  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
1720  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
1721  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
1722  self.assertEqual((True,1),p.values["ref4"][1][0].values["a"])
self.assertEqual((True,1),p.values["ref4"][1][1].values["a"])
def Config.TestModuleCommand.testSchedule (   self)

Definition at line 1467 of file Config.py.

1468  def testSchedule(self):
1469  p = Process("test")
1470  p.a = EDAnalyzer("MyAnalyzer")
1471  p.b = EDAnalyzer("YourAnalyzer")
1472  p.c = EDAnalyzer("OurAnalyzer")
1473  p.d = EDAnalyzer("OurAnalyzer")
1474  p.path1 = Path(p.a)
1475  p.path2 = Path(p.b)
1476  p.path3 = Path(p.d)
1477 
1478  s = Schedule(p.path1,p.path2)
1479  self.assertEqual(s[0],p.path1)
1480  self.assertEqual(s[1],p.path2)
1481  p.schedule = s
1482  self.assert_('b' in p.schedule.moduleNames())
1483  self.assert_(hasattr(p, 'b'))
1484  self.assert_(hasattr(p, 'c'))
1485  self.assert_(hasattr(p, 'd'))
1486  self.assert_(hasattr(p, 'path1'))
1487  self.assert_(hasattr(p, 'path2'))
1488  self.assert_(hasattr(p, 'path3'))
1489  p.prune()
1490  self.assert_('b' in p.schedule.moduleNames())
1491  self.assert_(hasattr(p, 'b'))
1492  self.assert_(not hasattr(p, 'c'))
1493  self.assert_(not hasattr(p, 'd'))
1494  self.assert_(hasattr(p, 'path1'))
1495  self.assert_(hasattr(p, 'path2'))
1496  self.assert_(not hasattr(p, 'path3'))
1497 
1498  #adding a path not attached to the Process should cause an exception
1499  p = Process("test")
1500  p.a = EDAnalyzer("MyAnalyzer")
1501  path1 = Path(p.a)
1502  s = Schedule(path1)
1503  self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) )
1504 
1505  #make sure anonymous sequences work
1506  p = Process("test")
1507  p.a = EDAnalyzer("MyAnalyzer")
1508  p.b = EDAnalyzer("MyOtherAnalyzer")
1509  p.c = EDProducer("MyProd")
1510  path1 = Path(p.c*Sequence(p.a+p.b))
1511  s = Schedule(path1)
1512  self.assert_('a' in s.moduleNames())
1513  self.assert_('b' in s.moduleNames())
1514  self.assert_('c' in s.moduleNames())
1515  p.path1 = path1
1516  p.schedule = s
1517  p.prune()
1518  self.assert_('a' in s.moduleNames())
1519  self.assert_('b' in s.moduleNames())
1520  self.assert_('c' in s.moduleNames())
def Config.TestModuleCommand.testSecSource (   self)

Definition at line 1389 of file Config.py.

References python.rootplot.root2matplotlib.replace().

1390  def testSecSource(self):
1391  p = Process('test')
1392  p.a = SecSource("MySecSource")
1393  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 1404 of file Config.py.

1405  def testSequence(self):
1406  p = Process('test')
1407  p.a = EDAnalyzer("MyAnalyzer")
1408  p.b = EDAnalyzer("YourAnalyzer")
1409  p.c = EDAnalyzer("OurAnalyzer")
1410  p.s = Sequence(p.a*p.b)
1411  self.assertEqual(str(p.s),'a+b')
1412  self.assertEqual(p.s.label_(),'s')
1413  path = Path(p.c+p.s)
1414  self.assertEqual(str(path),'c+a+b')
1415  p._validateSequence(path, 'p1')
1416  notInProcess = EDAnalyzer('NotInProcess')
1417  p2 = Path(p.c+p.s*notInProcess)
1418  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 1419 of file Config.py.

1420  def testSequence2(self):
1421  p = Process('test')
1422  p.a = EDAnalyzer("MyAnalyzer")
1423  p.b = EDAnalyzer("YourAnalyzer")
1424  p.c = EDAnalyzer("OurAnalyzer")
1425  testseq = Sequence(p.a*p.b)
1426  p.s = testseq
1427  #p.y = testseq
1428  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 1668 of file Config.py.

References cond.hash.

1669  def testSubProcess(self):
1670  process = Process("Parent")
1671  subProcess = Process("Child")
1672  subProcess.a = EDProducer("A")
1673  subProcess.p = Path(subProcess.a)
1674  subProcess.add_(Service("Foo"))
1675  process.add_( SubProcess(subProcess) )
1676  d = process.dumpPython()
1677  equalD ="""import FWCore.ParameterSet.Config as cms
1678 
1679 process = cms.Process("Parent")
1680 
1681 parentProcess = process
1682 import FWCore.ParameterSet.Config as cms
1683 
1684 process = cms.Process("Child")
1685 
1686 process.a = cms.EDProducer("A")
1687 
1688 
1689 process.p = cms.Path(process.a)
1690 
1691 
1692 process.Foo = cms.Service("Foo")
1693 
1694 
1695 childProcess = process
1696 process = parentProcess
1697 process.subProcess = cms.SubProcess( process = childProcess, SelectEvents = cms.untracked.PSet(
1698 
1699 ), outputCommands = cms.untracked.vstring())
1700 """
1701  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcess)))
1702  self.assertEqual(d,equalD)
1703  p = TestMakePSet()
1704  process.subProcess.insertInto(p,"dummy")
1705  self.assertEqual((True,['a']),p.values["@sub_process"][1].values["process"][1].values['@all_modules'])
1706  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 1192 of file Config.py.

1193  def testTypedParameterizable(self):
1194  p = _TypedParameterizable("blah", b=int32(1))
1195  #see if copy works deeply
1196  other = p.copy()
1197  other.b = 2
1198  self.assertNotEqual(p.b,other.b)
def Config.TestModuleCommand.testUsing (   self)

Definition at line 1554 of file Config.py.

1555  def testUsing(self):
1556  p = Process('test')
1557  p.block = PSet(a = int32(1))
1558  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
1559  self.assertEqual(p.modu.a.value(),1)
1560  self.assertEqual(p.modu.b.value(),2)

Member Data Documentation

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

Definition at line 1368 of file Config.py.

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

Definition at line 1361 of file Config.py.

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

Definition at line 1364 of file Config.py.