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

Member Function Documentation

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

Definition at line 1232 of file Config.py.

1233  def setUp(self):
1234  """Nothing to do """
None
def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 1527 of file Config.py.

1528  def testCloneSequence(self):
1529  p = Process("test")
1530  a = EDAnalyzer("MyAnalyzer")
1531  p.a = a
1532  a.setLabel("a")
1533  b = EDAnalyzer("YOurAnalyzer")
1534  p.b = b
1535  b.setLabel("b")
1536  path = Path(a * b)
1537  p.path = Path(p.a*p.b)
1538  lookuptable = {id(a): p.a, id(b): p.b}
1539  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1540  #lookuptable = p._cloneToObjectDict
1541  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1542  self.assertEqual(str(path),str(p.path))
def Config.TestModuleCommand.testExamples (   self)

Definition at line 1660 of file Config.py.

References Types.untracked.

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

Definition at line 1726 of file Config.py.

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

Definition at line 1470 of file Config.py.

1471  def testGlobalReplace(self):
1472  p = Process('test')
1473  p.a = EDAnalyzer("MyAnalyzer")
1474  p.b = EDAnalyzer("YourAnalyzer")
1475  p.c = EDAnalyzer("OurAnalyzer")
1476  p.s = Sequence(p.a*p.b)
1477  p.p = Path(p.c+p.s+p.a)
1478  new = EDAnalyzer("NewAnalyzer")
1479  p.globalReplace("a",new)
def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 1597 of file Config.py.

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

Definition at line 1882 of file Config.py.

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

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

Definition at line 1637 of file Config.py.

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

Definition at line 1235 of file Config.py.

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

1506  def testPath(self):
1507  p = Process("test")
1508  p.a = EDAnalyzer("MyAnalyzer")
1509  p.b = EDAnalyzer("YourAnalyzer")
1510  p.c = EDAnalyzer("OurAnalyzer")
1511  path = Path(p.a)
1512  path *= p.b
1513  path += 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 #This leads to problems with sequences
1518 # self.assertEqual(str(path),'((a*b)+c)')
1519  path = Path(p.a+ p.b*p.c)
1520  self.assertEqual(str(path),'a+b+c')
1521  path = Path(p.a*(p.b+p.c))
1522  self.assertEqual(str(path),'a+b+c')
1523  path = Path(p.a*(p.b+~p.c))
1524  self.assertEqual(str(path),'a+b+~c')
1525  p.es = ESProducer("AnESProducer")
1526  self.assertRaises(TypeError,Path,p.es)
def Config.TestModuleCommand.testPrefers (   self)

Definition at line 1672 of file Config.py.

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

Definition at line 1370 of file Config.py.

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

Definition at line 1300 of file Config.py.

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

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

Definition at line 1275 of file Config.py.

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

Definition at line 1799 of file Config.py.

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

1784  def testRefToPSet(self):
1785  proc = Process("test")
1786  proc.top = PSet(a = int32(1))
1787  proc.ref = PSet(refToPSet_ = string("top"))
1788  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
1789  proc.ref3 = PSet(refToPSet_ = string("ref"))
1790  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
1791  PSet(refToPSet_ = string("ref2")))
1792  p = TestMakePSet()
1793  proc.fillProcessDesc(p)
1794  self.assertEqual((True,1),p.values["ref"][1].values["a"])
1795  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
1796  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
1797  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
1798  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 1543 of file Config.py.

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

Definition at line 1465 of file Config.py.

References python.rootplot.root2matplotlib.replace().

1466  def testSecSource(self):
1467  p = Process('test')
1468  p.a = SecSource("MySecSource")
1469  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 1480 of file Config.py.

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

Definition at line 1495 of file Config.py.

1496  def testSequence2(self):
1497  p = Process('test')
1498  p.a = EDAnalyzer("MyAnalyzer")
1499  p.b = EDAnalyzer("YourAnalyzer")
1500  p.c = EDAnalyzer("OurAnalyzer")
1501  testseq = Sequence(p.a*p.b)
1502  p.s = testseq
1503  #p.y = testseq
1504  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 1744 of file Config.py.

References cond.hash.

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

1269  def testTypedParameterizable(self):
1270  p = _TypedParameterizable("blah", b=int32(1))
1271  #see if copy works deeply
1272  other = p.copy()
1273  other.b = 2
1274  self.assertNotEqual(p.b,other.b)
def Config.TestModuleCommand.testUsing (   self)

Definition at line 1630 of file Config.py.

1631  def testUsing(self):
1632  p = Process('test')
1633  p.block = PSet(a = int32(1))
1634  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
1635  self.assertEqual(p.modu.a.value(),1)
1636  self.assertEqual(p.modu.b.value(),2)

Member Data Documentation

Config.TestModuleCommand.a

Definition at line 1920 of file Config.py.

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

Definition at line 1444 of file Config.py.

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

Definition at line 1437 of file Config.py.

Config.TestModuleCommand.proc_mod_

Definition at line 1917 of file Config.py.

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

Definition at line 1440 of file Config.py.