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

Member Function Documentation

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

Definition at line 1224 of file Config.py.

1225  def setUp(self):
1226  """Nothing to do """
None
def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 1519 of file Config.py.

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

Definition at line 1652 of file Config.py.

References Types.untracked.

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

Definition at line 1718 of file Config.py.

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

Definition at line 1462 of file Config.py.

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

Definition at line 1589 of file Config.py.

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

Definition at line 1864 of file Config.py.

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

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

Definition at line 1629 of file Config.py.

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

Definition at line 1227 of file Config.py.

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

1498  def testPath(self):
1499  p = Process("test")
1500  p.a = EDAnalyzer("MyAnalyzer")
1501  p.b = EDAnalyzer("YourAnalyzer")
1502  p.c = EDAnalyzer("OurAnalyzer")
1503  path = Path(p.a)
1504  path *= p.b
1505  path += p.c
1506  self.assertEqual(str(path),'a+b+c')
1507  path = Path(p.a*p.b+p.c)
1508  self.assertEqual(str(path),'a+b+c')
1509 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
1510 # self.assertEqual(str(path),'((a*b)+c)')
1511  path = Path(p.a+ p.b*p.c)
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  p.es = ESProducer("AnESProducer")
1518  self.assertRaises(TypeError,Path,p.es)
def Config.TestModuleCommand.testPrefers (   self)

Definition at line 1664 of file Config.py.

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

Definition at line 1362 of file Config.py.

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

Definition at line 1292 of file Config.py.

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

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

Definition at line 1267 of file Config.py.

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

Definition at line 1791 of file Config.py.

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

Definition at line 1775 of file Config.py.

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

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

Definition at line 1457 of file Config.py.

References python.rootplot.root2matplotlib.replace().

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

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

Definition at line 1487 of file Config.py.

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

Definition at line 1736 of file Config.py.

References cond.hash.

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

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

Definition at line 1622 of file Config.py.

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

Member Data Documentation

Config.TestModuleCommand.a

Definition at line 1902 of file Config.py.

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

Definition at line 1436 of file Config.py.

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

Definition at line 1429 of file Config.py.

Config.TestModuleCommand.proc_mod_

Definition at line 1899 of file Config.py.

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

Definition at line 1432 of file Config.py.