CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | 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
 

Public Attributes

 a
 
 proc_mod_
 

Static Public Attributes

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

Detailed Description

Definition at line 1225 of file Config.py.

Member Function Documentation

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

Definition at line 1226 of file Config.py.

1227  def setUp(self):
1228  """Nothing to do """
None
def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 1521 of file Config.py.

1522  def testCloneSequence(self):
1523  p = Process("test")
1524  a = EDAnalyzer("MyAnalyzer")
1525  p.a = a
1526  a.setLabel("a")
1527  b = EDAnalyzer("YOurAnalyzer")
1528  p.b = b
1529  b.setLabel("b")
1530  path = Path(a * b)
1531  p.path = Path(p.a*p.b)
1532  lookuptable = {id(a): p.a, id(b): p.b}
1533  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1534  #lookuptable = p._cloneToObjectDict
1535  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1536  self.assertEqual(str(path),str(p.path))
def Config.TestModuleCommand.testExamples (   self)

Definition at line 1654 of file Config.py.

References Types.untracked.

1655  def testExamples(self):
1656  p = Process("Test")
1657  p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root")))
1658  p.foos = EDProducer("FooProducer")
1659  p.bars = EDProducer("BarProducer", foos=InputTag("foos"))
1660  p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root")))
1661  p.bars.foos = 'Foosball'
1662  self.assertEqual(p.bars.foos, InputTag('Foosball'))
1663  p.p = Path(p.foos*p.bars)
1664  p.e = EndPath(p.out)
1665  p.add_(Service("MessageLogger"))
tuple untracked
Definition: Types.py:27
def Config.TestModuleCommand.testFreeze (   self)

Definition at line 1720 of file Config.py.

1721  def testFreeze(self):
1722  process = Process("Freeze")
1723  m = EDProducer("M", p=PSet(i = int32(1)))
1724  m.p.i = 2
1725  process.m = m
1726  # should be frozen
1727  #self.assertRaises(ValueError, setattr, m.p, 'i', 3)
1728  #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1)))
1729  #self.assertRaises(ValueError, setattr, m.p, 'j', 1)
1730  #self.assertRaises(ValueError, setattr, m, 'j', 1)
1731  # But OK to change through the process
1732  process.m.p.i = 4
1733  self.assertEqual(process.m.p.i.value(), 4)
1734  process.m.p = PSet(j=int32(1))
1735  # should work to clone it, though
1736  m2 = m.clone(p = PSet(i = int32(5)), j = int32(8))
1737  m2.p.i = 6
m2.j = 8
def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 1464 of file Config.py.

1465  def testGlobalReplace(self):
1466  p = Process('test')
1467  p.a = EDAnalyzer("MyAnalyzer")
1468  p.b = EDAnalyzer("YourAnalyzer")
1469  p.c = EDAnalyzer("OurAnalyzer")
1470  p.s = Sequence(p.a*p.b)
1471  p.p = Path(p.c+p.s+p.a)
1472  new = EDAnalyzer("NewAnalyzer")
1473  p.globalReplace("a",new)
def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 1591 of file Config.py.

1592  def testImplicitSchedule(self):
1593  p = Process("test")
1594  p.a = EDAnalyzer("MyAnalyzer")
1595  p.b = EDAnalyzer("YourAnalyzer")
1596  p.c = EDAnalyzer("OurAnalyzer")
1597  p.path1 = Path(p.a)
1598  p.path2 = Path(p.b)
1599  self.assert_(p.schedule is None)
1600  pths = p.paths
1601  keys = pths.keys()
1602  self.assertEqual(pths[keys[0]],p.path1)
1603  self.assertEqual(pths[keys[1]],p.path2)
1604  p.prune()
1605  self.assert_(hasattr(p, 'a'))
1606  self.assert_(hasattr(p, 'b'))
1607  self.assert_(not hasattr(p, 'c'))
1608  self.assert_(hasattr(p, 'path1'))
1609  self.assert_(hasattr(p, 'path2'))
1610 
1611 
1612  p = Process("test")
1613  p.a = EDAnalyzer("MyAnalyzer")
1614  p.b = EDAnalyzer("YourAnalyzer")
1615  p.c = EDAnalyzer("OurAnalyzer")
1616  p.path2 = Path(p.b)
1617  p.path1 = Path(p.a)
1618  self.assert_(p.schedule is None)
1619  pths = p.paths
1620  keys = pths.keys()
1621  self.assertEqual(pths[keys[1]],p.path1)
1622  self.assertEqual(pths[keys[0]],p.path2)
1623 
def Config.TestModuleCommand.testModifier (   self)

Definition at line 1876 of file Config.py.

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

1877  def testModifier(self):
1878  m1 = Modifier()
1879  p = Process("test",m1)
1880  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1881  def _mod_fred(obj):
1882  obj.fred = 2
1883  m1.toModify(p.a,_mod_fred)
1884  self.assertEqual(p.a.fred.value(),2)
1885  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1886  m1.toModify(p.b, wilma = 2)
1887  self.assertEqual(p.b.wilma.value(),2)
1888  #check that Modifier not attached to a process doesn't run
1889  m1 = Modifier()
1890  p = Process("test")
1891  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1892  m1.toModify(p.a,_mod_fred)
1893  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1894  m1.toModify(p.b, wilma = 2)
1895  self.assertEqual(p.a.fred.value(),1)
1896  self.assertEqual(p.b.wilma.value(),1)
1897  #make sure clones get the changes
1898  m1 = Modifier()
1899  p = Process("test",m1)
1900  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
1901  m1.toModify(p.a, fred = int32(2))
1902  p.b = p.a.clone(wilma = int32(3))
1903  self.assertEqual(p.a.fred.value(),2)
1904  self.assertEqual(p.a.wilma.value(),1)
1905  self.assertEqual(p.b.fred.value(),2)
1906  self.assertEqual(p.b.wilma.value(),3)
1907  #test that load causes process wide methods to run
1908  def _rem_a(proc):
1909  del proc.a
1910  class ProcModifierMod(object):
1911  def __init__(self,modifier,func):
1912  self.proc_mod_ = modifier.makeProcessModifier(func)
1913  class DummyMod(object):
1914  def __init__(self):
1915  self.a = EDAnalyzer("Dummy")
1916  testMod = DummyMod()
1917  p.extend(testMod)
1918  self.assert_(hasattr(p,"a"))
1919  m1 = Modifier()
1920  p = Process("test",m1)
1921  testProcMod = ProcModifierMod(m1,_rem_a)
1922  p.extend(testMod)
1923  p.extend(testProcMod)
1924  self.assert_(not hasattr(p,"a"))
1925  #test ModifierChain
1926  m1 = Modifier()
1927  mc = ModifierChain(m1)
1928  p = Process("test",mc)
1929  testMod = DummyMod()
1930  p.b = EDAnalyzer("Dummy2", fred = int32(1))
1931  m1.toModify(p.b, fred = int32(3))
1932  p.extend(testMod)
1933  testProcMod = ProcModifierMod(m1,_rem_a)
1934  p.extend(testProcMod)
1935  self.assert_(not hasattr(p,"a"))
1936  self.assertEqual(p.b.fred.value(),3)
1937 
1938 
unittest.main()
list object
Definition: dbtoconf.py:77
def Config.TestModuleCommand.testOverride (   self)

Definition at line 1631 of file Config.py.

1632  def testOverride(self):
1633  p = Process('test')
1634  a = EDProducer("A", a1=int32(0))
1635  self.assert_(not a.isModified())
1636  a.a1 = 1
1637  self.assert_(a.isModified())
1638  p.a = a
1639  self.assertEqual(p.a.a1.value(), 1)
1640  # try adding an unmodified module.
1641  # should accept it
1642  p.a = EDProducer("A", a1=int32(2))
1643  self.assertEqual(p.a.a1.value(), 2)
1644  # try adding a modified module. Should throw
1645  # no longer, since the same (modified) say, geometry
1646  # could come from more than one cff
1647  b = EDProducer("A", a1=int32(3))
1648  b.a1 = 4
1649  #self.assertRaises(RuntimeError, setattr, *(p,'a',b))
1650  ps1 = PSet(a = int32(1))
1651  ps2 = PSet(a = int32(2))
1652  self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2)
1653  self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
def Config.TestModuleCommand.testParameterizable (   self)

Definition at line 1229 of file Config.py.

1230  def testParameterizable(self):
1231  p = _Parameterizable()
1232  self.assertEqual(len(p.parameterNames_()),0)
1233  p.a = int32(1)
1234  self.assert_('a' in p.parameterNames_())
1235  self.assertEqual(p.a.value(), 1)
1236  p.a = 10
1237  self.assertEqual(p.a.value(), 10)
1238  p.a = untracked(int32(1))
1239  self.assertEqual(p.a.value(), 1)
1240  self.failIf(p.a.isTracked())
1241  p.a = untracked.int32(1)
1242  self.assertEqual(p.a.value(), 1)
1243  self.failIf(p.a.isTracked())
1244  p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0)))
1245  self.assertEqual(p.foo.value(), 10)
1246  self.assertEqual(p.bar.value(),1.0)
1247  self.failIf(p.bar.isTracked())
1248  self.assertRaises(TypeError,setattr,(p,'c',1))
1249  p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0))))
1250  self.assertEqual(p.a.foo.value(),10)
1251  self.assertEqual(p.a.bar.value(),1.0)
1252  p.b = untracked(PSet(fii = int32(1)))
1253  self.assertEqual(p.b.fii.value(),1)
1254  self.failIf(p.b.isTracked())
1255  #test the fact that values can be shared
1256  v = int32(10)
1257  p=_Parameterizable(a=v)
1258  v.setValue(11)
1259  self.assertEqual(p.a.value(),11)
1260  p.a = 12
1261  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 1499 of file Config.py.

1500  def testPath(self):
1501  p = Process("test")
1502  p.a = EDAnalyzer("MyAnalyzer")
1503  p.b = EDAnalyzer("YourAnalyzer")
1504  p.c = EDAnalyzer("OurAnalyzer")
1505  path = Path(p.a)
1506  path *= p.b
1507  path += p.c
1508  self.assertEqual(str(path),'a+b+c')
1509  path = Path(p.a*p.b+p.c)
1510  self.assertEqual(str(path),'a+b+c')
1511 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
1512 # self.assertEqual(str(path),'((a*b)+c)')
1513  path = Path(p.a+ p.b*p.c)
1514  self.assertEqual(str(path),'a+b+c')
1515  path = Path(p.a*(p.b+p.c))
1516  self.assertEqual(str(path),'a+b+c')
1517  path = Path(p.a*(p.b+~p.c))
1518  self.assertEqual(str(path),'a+b+~c')
1519  p.es = ESProducer("AnESProducer")
1520  self.assertRaises(TypeError,Path,p.es)
def Config.TestModuleCommand.testPrefers (   self)

Definition at line 1666 of file Config.py.

1667  def testPrefers(self):
1668  p = Process("Test")
1669  p.add_(ESSource("ForceSource"))
1670  p.juicer = ESProducer("JuicerProducer")
1671  p.prefer("ForceSource")
1672  p.prefer("juicer")
1673  self.assertEqual(p.dumpConfig(),
1674 """process Test = {
1675  es_module juicer = JuicerProducer {
1676  }
1677  es_source = ForceSource {
1678  }
1679  es_prefer = ForceSource {
1680  }
1681  es_prefer juicer = JuicerProducer {
1682  }
1683 }
1684 """)
1685  p.prefer("juicer",fooRcd=vstring("Foo"))
1686  self.assertEqual(p.dumpConfig(),
1687 """process Test = {
1688  es_module juicer = JuicerProducer {
1689  }
1690  es_source = ForceSource {
1691  }
1692  es_prefer = ForceSource {
1693  }
1694  es_prefer juicer = JuicerProducer {
1695  vstring fooRcd = {
1696  'Foo'
1697  }
1698 
1699  }
1700 }
1701 """)
1702  self.assertEqual(p.dumpPython(),
1703 """import FWCore.ParameterSet.Config as cms
1704 
1705 process = cms.Process("Test")
1706 
1707 process.juicer = cms.ESProducer("JuicerProducer")
1708 
1709 
1710 process.ForceSource = cms.ESSource("ForceSource")
1711 
1712 
1713 process.prefer("ForceSource")
1714 
1715 process.prefer("juicer",
1716  fooRcd = cms.vstring('Foo')
1717 )
1718 
1719 """)
def Config.TestModuleCommand.testProcessDumpPython (   self)

Definition at line 1364 of file Config.py.

1365  def testProcessDumpPython(self):
1366  p = Process("test")
1367  p.a = EDAnalyzer("MyAnalyzer")
1368  p.p = Path(p.a)
1369  p.s = Sequence(p.a)
1370  p.r = Sequence(p.s)
1371  p.p2 = Path(p.s)
1372  p.schedule = Schedule(p.p2,p.p)
1373  d=p.dumpPython()
1374  self.assertEqual(d,
1375 """import FWCore.ParameterSet.Config as cms
1376 
1377 process = cms.Process("test")
1378 
1379 process.a = cms.EDAnalyzer("MyAnalyzer")
1380 
1381 
1382 process.s = cms.Sequence(process.a)
1383 
1384 
1385 process.r = cms.Sequence(process.s)
1386 
1387 
1388 process.p = cms.Path(process.a)
1389 
1390 
1391 process.p2 = cms.Path(process.s)
1392 
1393 
1394 process.schedule = cms.Schedule(*[ process.p2, process.p ])
1395 """)
1396  #Reverse order of 'r' and 's'
1397  p = Process("test")
1398  p.a = EDAnalyzer("MyAnalyzer")
1399  p.p = Path(p.a)
1400  p.r = Sequence(p.a)
1401  p.s = Sequence(p.r)
1402  p.p2 = Path(p.r)
1403  p.schedule = Schedule(p.p2,p.p)
1404  p.b = EDAnalyzer("YourAnalyzer")
1405  d=p.dumpPython()
1406  self.assertEqual(d,
1407 """import FWCore.ParameterSet.Config as cms
1408 
1409 process = cms.Process("test")
1410 
1411 process.a = cms.EDAnalyzer("MyAnalyzer")
1412 
1413 
1414 process.b = cms.EDAnalyzer("YourAnalyzer")
1415 
1416 
1417 process.r = cms.Sequence(process.a)
1418 
1419 
1420 process.s = cms.Sequence(process.r)
1421 
1422 
1423 process.p = cms.Path(process.a)
1424 
1425 
1426 process.p2 = cms.Path(process.r)
1427 
1428 
1429 process.schedule = cms.Schedule(*[ process.p2, process.p ])
""")
def Config.TestModuleCommand.testProcessExtend (   self)

Definition at line 1294 of file Config.py.

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

1295  def testProcessExtend(self):
1296  class FromArg(object):
1297  def __init__(self,*arg,**args):
1298  for name in args.iterkeys():
1299  self.__dict__[name]=args[name]
1300 
1301  a=EDAnalyzer("MyAnalyzer")
1302  t=EDAnalyzer("MyAnalyzer")
1303  t.setLabel("foo")
1304  s1 = Sequence(a)
1305  s2 = Sequence(s1)
1306  s3 = Sequence(s2)
1307  d = FromArg(
1308  a=a,
1309  b=Service("Full"),
1310  c=Path(a),
1311  d=s2,
1312  e=s1,
1313  f=s3,
1314  g=Sequence(s1+s2+s3)
1315  )
1316  p = Process("Test")
1317  p.extend(d)
1318  self.assertEqual(p.a.type_(),"MyAnalyzer")
1319  self.assertEqual(p.a.label_(),"a")
1320  self.assertRaises(AttributeError,getattr,p,'b')
1321  self.assertEqual(p.Full.type_(),"Full")
1322  self.assertEqual(str(p.c),'a')
1323  self.assertEqual(str(p.d),'a')
1324 
1325  z1 = FromArg(
1326  a=a,
1327  b=Service("Full"),
1328  c=Path(a),
1329  d=s2,
1330  e=s1,
1331  f=s3,
1332  s4=s3,
1333  g=Sequence(s1+s2+s3)
1334  )
1335 
1336  p1 = Process("Test")
1337  #p1.extend(z1)
1338  self.assertRaises(ValueError, p1.extend, z1)
1339 
1340  z2 = FromArg(
1341  a=a,
1342  b=Service("Full"),
1343  c=Path(a),
1344  d=s2,
1345  e=s1,
1346  f=s3,
1347  aaa=copy.deepcopy(a),
1348  s4=copy.deepcopy(s3),
1349  g=Sequence(s1+s2+s3),
1350  t=t
1351  )
1352  p2 = Process("Test")
1353  p2.extend(z2)
1354  #self.assertRaises(ValueError, p2.extend, z2)
1355  self.assertEqual(p2.s4.label_(),"s4")
1356  #p2.s4.setLabel("foo")
1357  self.assertRaises(ValueError, p2.s4.setLabel, "foo")
1358  p2.s4.setLabel("s4")
1359  p2.s4.setLabel(None)
1360  p2.s4.setLabel("foo")
1361  p2._Process__setObjectLabel(p2.s4, "foo")
1362  p2._Process__setObjectLabel(p2.s4, None)
1363  p2._Process__setObjectLabel(p2.s4, "bar")
list object
Definition: dbtoconf.py:77
def Config.TestModuleCommand.testProcessInsertion (   self)

Definition at line 1269 of file Config.py.

1270  def testProcessInsertion(self):
1271  p = Process("test")
1272  p.a = EDAnalyzer("MyAnalyzer")
1273  self.assert_( 'a' in p.analyzers_() )
1274  self.assert_( 'a' in p.analyzers)
1275  p.add_(Service("MessageLogger"))
1276  self.assert_('MessageLogger' in p.services_())
1277  self.assertEqual(p.MessageLogger.type_(), "MessageLogger")
1278  p.Tracer = Service("Tracer")
1279  self.assert_('Tracer' in p.services_())
1280  self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
1281  self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger")))
1282  self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource")))
1283  p.out = OutputModule("Outer")
1284  self.assertEqual(p.out.type_(), 'Outer')
1285  self.assert_( 'out' in p.outputModules_() )
1286 
1287  p.geom = ESSource("GeomProd")
1288  self.assert_('geom' in p.es_sources_())
1289  p.add_(ESSource("ConfigDB"))
1290  self.assert_('ConfigDB' in p.es_sources_())
1291 
1292  p.aliasfoo1 = EDAlias(foo1 = VPSet(PSet(type = string("Foo1"))))
1293  self.assert_('aliasfoo1' in p.aliases_())
def Config.TestModuleCommand.testPrune (   self)

Definition at line 1793 of file Config.py.

1794  def testPrune(self):
1795  p = Process("test")
1796  p.a = EDAnalyzer("MyAnalyzer")
1797  p.b = EDAnalyzer("YourAnalyzer")
1798  p.c = EDAnalyzer("OurAnalyzer")
1799  p.d = EDAnalyzer("OurAnalyzer")
1800  p.s = Sequence(p.d)
1801  p.path1 = Path(p.a)
1802  p.path2 = Path(p.b)
1803  self.assert_(p.schedule is None)
1804  pths = p.paths
1805  keys = pths.keys()
1806  self.assertEqual(pths[keys[0]],p.path1)
1807  self.assertEqual(pths[keys[1]],p.path2)
1808  p.pset1 = PSet(parA = string("pset1"))
1809  p.pset2 = untracked.PSet(parA = string("pset2"))
1810  p.vpset1 = VPSet()
1811  p.vpset2 = untracked.VPSet()
1812  p.prune()
1813  self.assert_(hasattr(p, 'a'))
1814  self.assert_(hasattr(p, 'b'))
1815  self.assert_(not hasattr(p, 'c'))
1816  self.assert_(not hasattr(p, 'd'))
1817  self.assert_(not hasattr(p, 's'))
1818  self.assert_(hasattr(p, 'path1'))
1819  self.assert_(hasattr(p, 'path2'))
1820 # self.assert_(not hasattr(p, 'pset1'))
1821 # self.assert_(hasattr(p, 'pset2'))
1822 # self.assert_(not hasattr(p, 'vpset1'))
1823 # self.assert_(not hasattr(p, 'vpset2'))
1824 
1825  p = Process("test")
1826  p.a = EDAnalyzer("MyAnalyzer")
1827  p.b = EDAnalyzer("YourAnalyzer")
1828  p.c = EDAnalyzer("OurAnalyzer")
1829  p.d = EDAnalyzer("OurAnalyzer")
1830  p.e = EDAnalyzer("OurAnalyzer")
1831  p.s = Sequence(p.d)
1832  p.s2 = Sequence(p.b)
1833  p.s3 = Sequence(p.e)
1834  p.path1 = Path(p.a)
1835  p.path2 = Path(p.b)
1836  p.path3 = Path(p.b+p.s2)
1837  p.path4 = Path(p.b+p.s3)
1838  p.schedule = Schedule(p.path1,p.path2,p.path3)
1839  pths = p.paths
1840  keys = pths.keys()
1841  self.assertEqual(pths[keys[0]],p.path1)
1842  self.assertEqual(pths[keys[1]],p.path2)
1843  p.prune()
1844  self.assert_(hasattr(p, 'a'))
1845  self.assert_(hasattr(p, 'b'))
1846  self.assert_(not hasattr(p, 'c'))
1847  self.assert_(not hasattr(p, 'd'))
1848  self.assert_(not hasattr(p, 'e'))
1849  self.assert_(not hasattr(p, 's'))
1850  self.assert_(hasattr(p, 's2'))
1851  self.assert_(not hasattr(p, 's3'))
1852  self.assert_(hasattr(p, 'path1'))
1853  self.assert_(hasattr(p, 'path2'))
1854  self.assert_(hasattr(p, 'path3'))
1855  self.assert_(not hasattr(p, 'path4'))
1856  #test SequencePlaceholder
1857  p = Process("test")
1858  p.a = EDAnalyzer("MyAnalyzer")
1859  p.b = EDAnalyzer("YourAnalyzer")
1860  p.s = Sequence(SequencePlaceholder("a")+p.b)
1861  p.pth = Path(p.s)
1862  p.prune()
1863  self.assert_(hasattr(p, 'a'))
1864  self.assert_(hasattr(p, 'b'))
1865  self.assert_(hasattr(p, 's'))
1866  self.assert_(hasattr(p, 'pth'))
1867  #test unresolved SequencePlaceholder
1868  p = Process("test")
1869  p.b = EDAnalyzer("YourAnalyzer")
1870  p.s = Sequence(SequencePlaceholder("a")+p.b)
1871  p.pth = Path(p.s)
1872  p.prune(keepUnresolvedSequencePlaceholders=True)
1873  self.assert_(hasattr(p, 'b'))
1874  self.assert_(hasattr(p, 's'))
1875  self.assert_(hasattr(p, 'pth'))
self.assertEqual(p.s.dumpPython(''),'cms.Sequence(cms.SequencePlaceholder("a")+process.b)\n')
def Config.TestModuleCommand.testRefToPSet (   self)

Definition at line 1777 of file Config.py.

1778  def testRefToPSet(self):
1779  proc = Process("test")
1780  proc.top = PSet(a = int32(1))
1781  proc.ref = PSet(refToPSet_ = string("top"))
1782  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
1783  proc.ref3 = PSet(refToPSet_ = string("ref"))
1784  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
1785  PSet(refToPSet_ = string("ref2")))
1786  p = TestMakePSet()
1787  proc.fillProcessDesc(p)
1788  self.assertEqual((True,1),p.values["ref"][1].values["a"])
1789  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
1790  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
1791  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
1792  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 1537 of file Config.py.

1538  def testSchedule(self):
1539  p = Process("test")
1540  p.a = EDAnalyzer("MyAnalyzer")
1541  p.b = EDAnalyzer("YourAnalyzer")
1542  p.c = EDAnalyzer("OurAnalyzer")
1543  p.d = EDAnalyzer("OurAnalyzer")
1544  p.path1 = Path(p.a)
1545  p.path2 = Path(p.b)
1546  p.path3 = Path(p.d)
1547 
1548  s = Schedule(p.path1,p.path2)
1549  self.assertEqual(s[0],p.path1)
1550  self.assertEqual(s[1],p.path2)
1551  p.schedule = s
1552  self.assert_('b' in p.schedule.moduleNames())
1553  self.assert_(hasattr(p, 'b'))
1554  self.assert_(hasattr(p, 'c'))
1555  self.assert_(hasattr(p, 'd'))
1556  self.assert_(hasattr(p, 'path1'))
1557  self.assert_(hasattr(p, 'path2'))
1558  self.assert_(hasattr(p, 'path3'))
1559  p.prune()
1560  self.assert_('b' in p.schedule.moduleNames())
1561  self.assert_(hasattr(p, 'b'))
1562  self.assert_(not hasattr(p, 'c'))
1563  self.assert_(not hasattr(p, 'd'))
1564  self.assert_(hasattr(p, 'path1'))
1565  self.assert_(hasattr(p, 'path2'))
1566  self.assert_(not hasattr(p, 'path3'))
1567 
1568  #adding a path not attached to the Process should cause an exception
1569  p = Process("test")
1570  p.a = EDAnalyzer("MyAnalyzer")
1571  path1 = Path(p.a)
1572  s = Schedule(path1)
1573  self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) )
1574 
1575  #make sure anonymous sequences work
1576  p = Process("test")
1577  p.a = EDAnalyzer("MyAnalyzer")
1578  p.b = EDAnalyzer("MyOtherAnalyzer")
1579  p.c = EDProducer("MyProd")
1580  path1 = Path(p.c*Sequence(p.a+p.b))
1581  s = Schedule(path1)
1582  self.assert_('a' in s.moduleNames())
1583  self.assert_('b' in s.moduleNames())
1584  self.assert_('c' in s.moduleNames())
1585  p.path1 = path1
1586  p.schedule = s
1587  p.prune()
1588  self.assert_('a' in s.moduleNames())
1589  self.assert_('b' in s.moduleNames())
1590  self.assert_('c' in s.moduleNames())
def Config.TestModuleCommand.testSecSource (   self)

Definition at line 1459 of file Config.py.

References python.rootplot.root2matplotlib.replace().

1460  def testSecSource(self):
1461  p = Process('test')
1462  p.a = SecSource("MySecSource")
1463  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 1474 of file Config.py.

1475  def testSequence(self):
1476  p = Process('test')
1477  p.a = EDAnalyzer("MyAnalyzer")
1478  p.b = EDAnalyzer("YourAnalyzer")
1479  p.c = EDAnalyzer("OurAnalyzer")
1480  p.s = Sequence(p.a*p.b)
1481  self.assertEqual(str(p.s),'a+b')
1482  self.assertEqual(p.s.label_(),'s')
1483  path = Path(p.c+p.s)
1484  self.assertEqual(str(path),'c+a+b')
1485  p._validateSequence(path, 'p1')
1486  notInProcess = EDAnalyzer('NotInProcess')
1487  p2 = Path(p.c+p.s*notInProcess)
1488  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 1489 of file Config.py.

1490  def testSequence2(self):
1491  p = Process('test')
1492  p.a = EDAnalyzer("MyAnalyzer")
1493  p.b = EDAnalyzer("YourAnalyzer")
1494  p.c = EDAnalyzer("OurAnalyzer")
1495  testseq = Sequence(p.a*p.b)
1496  p.s = testseq
1497  #p.y = testseq
1498  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 1738 of file Config.py.

References cond.hash.

1739  def testSubProcess(self):
1740  process = Process("Parent")
1741  subProcess = Process("Child")
1742  subProcess.a = EDProducer("A")
1743  subProcess.p = Path(subProcess.a)
1744  subProcess.add_(Service("Foo"))
1745  process.add_( SubProcess(subProcess) )
1746  d = process.dumpPython()
1747  equalD ="""import FWCore.ParameterSet.Config as cms
1748 
1749 process = cms.Process("Parent")
1750 
1751 parentProcess = process
1752 import FWCore.ParameterSet.Config as cms
1753 
1754 process = cms.Process("Child")
1755 
1756 process.a = cms.EDProducer("A")
1757 
1758 
1759 process.p = cms.Path(process.a)
1760 
1761 
1762 process.Foo = cms.Service("Foo")
1763 
1764 
1765 childProcess = process
1766 process = parentProcess
1767 process.subProcess = cms.SubProcess( process = childProcess, SelectEvents = cms.untracked.PSet(
1768 
1769 ), outputCommands = cms.untracked.vstring())
1770 """
1771  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcess)))
1772  self.assertEqual(d,equalD)
1773  p = TestMakePSet()
1774  process.subProcess.insertInto(p,"dummy")
1775  self.assertEqual((True,['a']),p.values["@sub_process"][1].values["process"][1].values['@all_modules'])
1776  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 1262 of file Config.py.

1263  def testTypedParameterizable(self):
1264  p = _TypedParameterizable("blah", b=int32(1))
1265  #see if copy works deeply
1266  other = p.copy()
1267  other.b = 2
1268  self.assertNotEqual(p.b,other.b)
def Config.TestModuleCommand.testUsing (   self)

Definition at line 1624 of file Config.py.

1625  def testUsing(self):
1626  p = Process('test')
1627  p.block = PSet(a = int32(1))
1628  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
1629  self.assertEqual(p.modu.a.value(),1)
1630  self.assertEqual(p.modu.b.value(),2)

Member Data Documentation

Config.TestModuleCommand.a

Definition at line 1914 of file Config.py.

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

Definition at line 1438 of file Config.py.

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

Definition at line 1431 of file Config.py.

Config.TestModuleCommand.proc_mod_

Definition at line 1911 of file Config.py.

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

Definition at line 1434 of file Config.py.