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
 

Static Public Attributes

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

Detailed Description

Definition at line 1183 of file Config.py.

Member Function Documentation

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

Definition at line 1184 of file Config.py.

1185  def setUp(self):
1186  """Nothing to do """
None
def Config.TestModuleCommand.testCloneSequence (   self)

Definition at line 1479 of file Config.py.

1480  def testCloneSequence(self):
1481  p = Process("test")
1482  a = EDAnalyzer("MyAnalyzer")
1483  p.a = a
1484  a.setLabel("a")
1485  b = EDAnalyzer("YOurAnalyzer")
1486  p.b = b
1487  b.setLabel("b")
1488  path = Path(a * b)
1489  p.path = Path(p.a*p.b)
1490  lookuptable = {id(a): p.a, id(b): p.b}
1491  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1492  #lookuptable = p._cloneToObjectDict
1493  #self.assertEqual(str(path),str(path._postProcessFixup(lookuptable)))
1494  self.assertEqual(str(path),str(p.path))
def Config.TestModuleCommand.testExamples (   self)

Definition at line 1612 of file Config.py.

References Types.untracked.

1613  def testExamples(self):
1614  p = Process("Test")
1615  p.source = Source("PoolSource",fileNames = untracked(string("file:reco.root")))
1616  p.foos = EDProducer("FooProducer")
1617  p.bars = EDProducer("BarProducer", foos=InputTag("foos"))
1618  p.out = OutputModule("PoolOutputModule",fileName=untracked(string("file:foos.root")))
1619  p.bars.foos = 'Foosball'
1620  self.assertEqual(p.bars.foos, InputTag('Foosball'))
1621  p.p = Path(p.foos*p.bars)
1622  p.e = EndPath(p.out)
1623  p.add_(Service("MessageLogger"))
tuple untracked
Definition: Types.py:27
def Config.TestModuleCommand.testFreeze (   self)

Definition at line 1678 of file Config.py.

1679  def testFreeze(self):
1680  process = Process("Freeze")
1681  m = EDProducer("M", p=PSet(i = int32(1)))
1682  m.p.i = 2
1683  process.m = m
1684  # should be frozen
1685  #self.assertRaises(ValueError, setattr, m.p, 'i', 3)
1686  #self.assertRaises(ValueError, setattr, m, 'p', PSet(i=int32(1)))
1687  #self.assertRaises(ValueError, setattr, m.p, 'j', 1)
1688  #self.assertRaises(ValueError, setattr, m, 'j', 1)
1689  # But OK to change through the process
1690  process.m.p.i = 4
1691  self.assertEqual(process.m.p.i.value(), 4)
1692  process.m.p = PSet(j=int32(1))
1693  # should work to clone it, though
1694  m2 = m.clone(p = PSet(i = int32(5)), j = int32(8))
1695  m2.p.i = 6
m2.j = 8
def Config.TestModuleCommand.testGlobalReplace (   self)

Definition at line 1422 of file Config.py.

1423  def testGlobalReplace(self):
1424  p = Process('test')
1425  p.a = EDAnalyzer("MyAnalyzer")
1426  p.b = EDAnalyzer("YourAnalyzer")
1427  p.c = EDAnalyzer("OurAnalyzer")
1428  p.s = Sequence(p.a*p.b)
1429  p.p = Path(p.c+p.s+p.a)
1430  new = EDAnalyzer("NewAnalyzer")
1431  p.globalReplace("a",new)
def Config.TestModuleCommand.testImplicitSchedule (   self)

Definition at line 1549 of file Config.py.

1550  def testImplicitSchedule(self):
1551  p = Process("test")
1552  p.a = EDAnalyzer("MyAnalyzer")
1553  p.b = EDAnalyzer("YourAnalyzer")
1554  p.c = EDAnalyzer("OurAnalyzer")
1555  p.path1 = Path(p.a)
1556  p.path2 = Path(p.b)
1557  self.assert_(p.schedule is None)
1558  pths = p.paths
1559  keys = pths.keys()
1560  self.assertEqual(pths[keys[0]],p.path1)
1561  self.assertEqual(pths[keys[1]],p.path2)
1562  p.prune()
1563  self.assert_(hasattr(p, 'a'))
1564  self.assert_(hasattr(p, 'b'))
1565  self.assert_(not hasattr(p, 'c'))
1566  self.assert_(hasattr(p, 'path1'))
1567  self.assert_(hasattr(p, 'path2'))
1568 
1569 
1570  p = Process("test")
1571  p.a = EDAnalyzer("MyAnalyzer")
1572  p.b = EDAnalyzer("YourAnalyzer")
1573  p.c = EDAnalyzer("OurAnalyzer")
1574  p.path2 = Path(p.b)
1575  p.path1 = Path(p.a)
1576  self.assert_(p.schedule is None)
1577  pths = p.paths
1578  keys = pths.keys()
1579  self.assertEqual(pths[keys[1]],p.path1)
1580  self.assertEqual(pths[keys[0]],p.path2)
1581 
def Config.TestModuleCommand.testModifier (   self)

Definition at line 1824 of file Config.py.

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

1825  def testModifier(self):
1826  m1 = Modifier()
1827  p = Process("test",m1)
1828  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1829  def _mod_fred(obj):
1830  obj.fred = 2
1831  m1.toModify(p.a,_mod_fred)
1832  self.assertEqual(p.a.fred.value(),2)
1833  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1834  m1.toModify(p.b, wilma = 2)
1835  self.assertEqual(p.b.wilma.value(),2)
1836  #check that Modifier not attached to a process doesn't run
1837  m1 = Modifier()
1838  p = Process("test")
1839  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1))
1840  m1.toModify(p.a,_mod_fred)
1841  p.b = EDAnalyzer("YourAnalyzer", wilma = int32(1))
1842  m1.toModify(p.b, wilma = 2)
1843  self.assertEqual(p.a.fred.value(),1)
1844  self.assertEqual(p.b.wilma.value(),1)
1845  #make sure clones get the changes
1846  m1 = Modifier()
1847  p = Process("test",m1)
1848  p.a = EDAnalyzer("MyAnalyzer", fred = int32(1), wilma = int32(1))
1849  m1.toModify(p.a, fred = int32(2))
1850  p.b = p.a.clone(wilma = int32(3))
1851  self.assertEqual(p.a.fred.value(),2)
1852  self.assertEqual(p.a.wilma.value(),1)
1853  self.assertEqual(p.b.fred.value(),2)
1854  self.assertEqual(p.b.wilma.value(),3)
1855  #test that load causes process wide methods to run
1856  def _rem_a(proc):
1857  del proc.a
1858  class DummyMod(object):
1859  def __init__(self):
1860  self.a = EDAnalyzer("Dummy")
1861  testMod = DummyMod()
1862  p.extend(testMod)
1863  self.assert_(hasattr(p,"a"))
1864  m1 = Modifier()
1865  p = Process("test",m1)
1866  m1.toModifyProcess(_rem_a)
1867  p.extend(testMod)
1868  self.assert_(not hasattr(p,"a"))
1869  #test ModifierChain
1870  m1 = Modifier()
1871  mc = ModifierChain(m1)
1872  p = Process("test",mc)
1873  testMod = DummyMod()
1874  m1.toModifyProcess(_rem_a)
1875  p.b = EDAnalyzer("Dummy2", fred = int32(1))
1876  m1.toModify(p.b, fred = int32(3))
1877  p.extend(testMod)
1878  self.assert_(not hasattr(p,"a"))
1879  self.assertEqual(p.b.fred.value(),3)
1880 
1881 
unittest.main()
list object
Definition: dbtoconf.py:77
def Config.TestModuleCommand.testOverride (   self)

Definition at line 1589 of file Config.py.

1590  def testOverride(self):
1591  p = Process('test')
1592  a = EDProducer("A", a1=int32(0))
1593  self.assert_(not a.isModified())
1594  a.a1 = 1
1595  self.assert_(a.isModified())
1596  p.a = a
1597  self.assertEqual(p.a.a1.value(), 1)
1598  # try adding an unmodified module.
1599  # should accept it
1600  p.a = EDProducer("A", a1=int32(2))
1601  self.assertEqual(p.a.a1.value(), 2)
1602  # try adding a modified module. Should throw
1603  # no longer, since the same (modified) say, geometry
1604  # could come from more than one cff
1605  b = EDProducer("A", a1=int32(3))
1606  b.a1 = 4
1607  #self.assertRaises(RuntimeError, setattr, *(p,'a',b))
1608  ps1 = PSet(a = int32(1))
1609  ps2 = PSet(a = int32(2))
1610  self.assertRaises(ValueError, EDProducer, 'C', ps1, ps2)
1611  self.assertRaises(ValueError, EDProducer, 'C', ps1, a=int32(3))
def Config.TestModuleCommand.testParameterizable (   self)

Definition at line 1187 of file Config.py.

1188  def testParameterizable(self):
1189  p = _Parameterizable()
1190  self.assertEqual(len(p.parameterNames_()),0)
1191  p.a = int32(1)
1192  self.assert_('a' in p.parameterNames_())
1193  self.assertEqual(p.a.value(), 1)
1194  p.a = 10
1195  self.assertEqual(p.a.value(), 10)
1196  p.a = untracked(int32(1))
1197  self.assertEqual(p.a.value(), 1)
1198  self.failIf(p.a.isTracked())
1199  p.a = untracked.int32(1)
1200  self.assertEqual(p.a.value(), 1)
1201  self.failIf(p.a.isTracked())
1202  p = _Parameterizable(foo=int32(10), bar = untracked(double(1.0)))
1203  self.assertEqual(p.foo.value(), 10)
1204  self.assertEqual(p.bar.value(),1.0)
1205  self.failIf(p.bar.isTracked())
1206  self.assertRaises(TypeError,setattr,(p,'c',1))
1207  p = _Parameterizable(a=PSet(foo=int32(10), bar = untracked(double(1.0))))
1208  self.assertEqual(p.a.foo.value(),10)
1209  self.assertEqual(p.a.bar.value(),1.0)
1210  p.b = untracked(PSet(fii = int32(1)))
1211  self.assertEqual(p.b.fii.value(),1)
1212  self.failIf(p.b.isTracked())
1213  #test the fact that values can be shared
1214  v = int32(10)
1215  p=_Parameterizable(a=v)
1216  v.setValue(11)
1217  self.assertEqual(p.a.value(),11)
1218  p.a = 12
1219  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 1457 of file Config.py.

1458  def testPath(self):
1459  p = Process("test")
1460  p.a = EDAnalyzer("MyAnalyzer")
1461  p.b = EDAnalyzer("YourAnalyzer")
1462  p.c = EDAnalyzer("OurAnalyzer")
1463  path = Path(p.a)
1464  path *= p.b
1465  path += p.c
1466  self.assertEqual(str(path),'a+b+c')
1467  path = Path(p.a*p.b+p.c)
1468  self.assertEqual(str(path),'a+b+c')
1469 # path = Path(p.a)*p.b+p.c #This leads to problems with sequences
1470 # self.assertEqual(str(path),'((a*b)+c)')
1471  path = Path(p.a+ p.b*p.c)
1472  self.assertEqual(str(path),'a+b+c')
1473  path = Path(p.a*(p.b+p.c))
1474  self.assertEqual(str(path),'a+b+c')
1475  path = Path(p.a*(p.b+~p.c))
1476  self.assertEqual(str(path),'a+b+~c')
1477  p.es = ESProducer("AnESProducer")
1478  self.assertRaises(TypeError,Path,p.es)
def Config.TestModuleCommand.testPrefers (   self)

Definition at line 1624 of file Config.py.

1625  def testPrefers(self):
1626  p = Process("Test")
1627  p.add_(ESSource("ForceSource"))
1628  p.juicer = ESProducer("JuicerProducer")
1629  p.prefer("ForceSource")
1630  p.prefer("juicer")
1631  self.assertEqual(p.dumpConfig(),
1632 """process Test = {
1633  es_module juicer = JuicerProducer {
1634  }
1635  es_source = ForceSource {
1636  }
1637  es_prefer = ForceSource {
1638  }
1639  es_prefer juicer = JuicerProducer {
1640  }
1641 }
1642 """)
1643  p.prefer("juicer",fooRcd=vstring("Foo"))
1644  self.assertEqual(p.dumpConfig(),
1645 """process Test = {
1646  es_module juicer = JuicerProducer {
1647  }
1648  es_source = ForceSource {
1649  }
1650  es_prefer = ForceSource {
1651  }
1652  es_prefer juicer = JuicerProducer {
1653  vstring fooRcd = {
1654  'Foo'
1655  }
1656 
1657  }
1658 }
1659 """)
1660  self.assertEqual(p.dumpPython(),
1661 """import FWCore.ParameterSet.Config as cms
1662 
1663 process = cms.Process("Test")
1664 
1665 process.juicer = cms.ESProducer("JuicerProducer")
1666 
1667 
1668 process.ForceSource = cms.ESSource("ForceSource")
1669 
1670 
1671 process.prefer("ForceSource")
1672 
1673 process.prefer("juicer",
1674  fooRcd = cms.vstring('Foo')
1675 )
1676 
1677 """)
def Config.TestModuleCommand.testProcessDumpPython (   self)

Definition at line 1322 of file Config.py.

1323  def testProcessDumpPython(self):
1324  p = Process("test")
1325  p.a = EDAnalyzer("MyAnalyzer")
1326  p.p = Path(p.a)
1327  p.s = Sequence(p.a)
1328  p.r = Sequence(p.s)
1329  p.p2 = Path(p.s)
1330  p.schedule = Schedule(p.p2,p.p)
1331  d=p.dumpPython()
1332  self.assertEqual(d,
1333 """import FWCore.ParameterSet.Config as cms
1334 
1335 process = cms.Process("test")
1336 
1337 process.a = cms.EDAnalyzer("MyAnalyzer")
1338 
1339 
1340 process.s = cms.Sequence(process.a)
1341 
1342 
1343 process.r = cms.Sequence(process.s)
1344 
1345 
1346 process.p = cms.Path(process.a)
1347 
1348 
1349 process.p2 = cms.Path(process.s)
1350 
1351 
1352 process.schedule = cms.Schedule(*[ process.p2, process.p ])
1353 """)
1354  #Reverse order of 'r' and 's'
1355  p = Process("test")
1356  p.a = EDAnalyzer("MyAnalyzer")
1357  p.p = Path(p.a)
1358  p.r = Sequence(p.a)
1359  p.s = Sequence(p.r)
1360  p.p2 = Path(p.r)
1361  p.schedule = Schedule(p.p2,p.p)
1362  p.b = EDAnalyzer("YourAnalyzer")
1363  d=p.dumpPython()
1364  self.assertEqual(d,
1365 """import FWCore.ParameterSet.Config as cms
1366 
1367 process = cms.Process("test")
1368 
1369 process.a = cms.EDAnalyzer("MyAnalyzer")
1370 
1371 
1372 process.b = cms.EDAnalyzer("YourAnalyzer")
1373 
1374 
1375 process.r = cms.Sequence(process.a)
1376 
1377 
1378 process.s = cms.Sequence(process.r)
1379 
1380 
1381 process.p = cms.Path(process.a)
1382 
1383 
1384 process.p2 = cms.Path(process.r)
1385 
1386 
1387 process.schedule = cms.Schedule(*[ process.p2, process.p ])
""")
def Config.TestModuleCommand.testProcessExtend (   self)

Definition at line 1252 of file Config.py.

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

1253  def testProcessExtend(self):
1254  class FromArg(object):
1255  def __init__(self,*arg,**args):
1256  for name in args.iterkeys():
1257  self.__dict__[name]=args[name]
1258 
1259  a=EDAnalyzer("MyAnalyzer")
1260  t=EDAnalyzer("MyAnalyzer")
1261  t.setLabel("foo")
1262  s1 = Sequence(a)
1263  s2 = Sequence(s1)
1264  s3 = Sequence(s2)
1265  d = FromArg(
1266  a=a,
1267  b=Service("Full"),
1268  c=Path(a),
1269  d=s2,
1270  e=s1,
1271  f=s3,
1272  g=Sequence(s1+s2+s3)
1273  )
1274  p = Process("Test")
1275  p.extend(d)
1276  self.assertEqual(p.a.type_(),"MyAnalyzer")
1277  self.assertEqual(p.a.label_(),"a")
1278  self.assertRaises(AttributeError,getattr,p,'b')
1279  self.assertEqual(p.Full.type_(),"Full")
1280  self.assertEqual(str(p.c),'a')
1281  self.assertEqual(str(p.d),'a')
1282 
1283  z1 = FromArg(
1284  a=a,
1285  b=Service("Full"),
1286  c=Path(a),
1287  d=s2,
1288  e=s1,
1289  f=s3,
1290  s4=s3,
1291  g=Sequence(s1+s2+s3)
1292  )
1293 
1294  p1 = Process("Test")
1295  #p1.extend(z1)
1296  self.assertRaises(ValueError, p1.extend, z1)
1297 
1298  z2 = FromArg(
1299  a=a,
1300  b=Service("Full"),
1301  c=Path(a),
1302  d=s2,
1303  e=s1,
1304  f=s3,
1305  aaa=copy.deepcopy(a),
1306  s4=copy.deepcopy(s3),
1307  g=Sequence(s1+s2+s3),
1308  t=t
1309  )
1310  p2 = Process("Test")
1311  p2.extend(z2)
1312  #self.assertRaises(ValueError, p2.extend, z2)
1313  self.assertEqual(p2.s4.label_(),"s4")
1314  #p2.s4.setLabel("foo")
1315  self.assertRaises(ValueError, p2.s4.setLabel, "foo")
1316  p2.s4.setLabel("s4")
1317  p2.s4.setLabel(None)
1318  p2.s4.setLabel("foo")
1319  p2._Process__setObjectLabel(p2.s4, "foo")
1320  p2._Process__setObjectLabel(p2.s4, None)
1321  p2._Process__setObjectLabel(p2.s4, "bar")
list object
Definition: dbtoconf.py:77
def Config.TestModuleCommand.testProcessInsertion (   self)

Definition at line 1227 of file Config.py.

1228  def testProcessInsertion(self):
1229  p = Process("test")
1230  p.a = EDAnalyzer("MyAnalyzer")
1231  self.assert_( 'a' in p.analyzers_() )
1232  self.assert_( 'a' in p.analyzers)
1233  p.add_(Service("MessageLogger"))
1234  self.assert_('MessageLogger' in p.services_())
1235  self.assertEqual(p.MessageLogger.type_(), "MessageLogger")
1236  p.Tracer = Service("Tracer")
1237  self.assert_('Tracer' in p.services_())
1238  self.assertRaises(TypeError, setattr, *(p,'b',"this should fail"))
1239  self.assertRaises(TypeError, setattr, *(p,'bad',Service("MessageLogger")))
1240  self.assertRaises(ValueError, setattr, *(p,'bad',Source("PoolSource")))
1241  p.out = OutputModule("Outer")
1242  self.assertEqual(p.out.type_(), 'Outer')
1243  self.assert_( 'out' in p.outputModules_() )
1244 
1245  p.geom = ESSource("GeomProd")
1246  self.assert_('geom' in p.es_sources_())
1247  p.add_(ESSource("ConfigDB"))
1248  self.assert_('ConfigDB' in p.es_sources_())
1249 
1250  p.aliasfoo1 = EDAlias(foo1 = VPSet(PSet(type = string("Foo1"))))
1251  self.assert_('aliasfoo1' in p.aliases_())
def Config.TestModuleCommand.testPrune (   self)

Definition at line 1751 of file Config.py.

1752  def testPrune(self):
1753  p = Process("test")
1754  p.a = EDAnalyzer("MyAnalyzer")
1755  p.b = EDAnalyzer("YourAnalyzer")
1756  p.c = EDAnalyzer("OurAnalyzer")
1757  p.d = EDAnalyzer("OurAnalyzer")
1758  p.s = Sequence(p.d)
1759  p.path1 = Path(p.a)
1760  p.path2 = Path(p.b)
1761  self.assert_(p.schedule is None)
1762  pths = p.paths
1763  keys = pths.keys()
1764  self.assertEqual(pths[keys[0]],p.path1)
1765  self.assertEqual(pths[keys[1]],p.path2)
1766  p.pset1 = PSet(parA = string("pset1"))
1767  p.pset2 = untracked.PSet(parA = string("pset2"))
1768  p.vpset1 = VPSet()
1769  p.vpset2 = untracked.VPSet()
1770  p.prune()
1771  self.assert_(hasattr(p, 'a'))
1772  self.assert_(hasattr(p, 'b'))
1773  self.assert_(not hasattr(p, 'c'))
1774  self.assert_(not hasattr(p, 'd'))
1775  self.assert_(not hasattr(p, 's'))
1776  self.assert_(hasattr(p, 'path1'))
1777  self.assert_(hasattr(p, 'path2'))
1778 # self.assert_(not hasattr(p, 'pset1'))
1779 # self.assert_(hasattr(p, 'pset2'))
1780 # self.assert_(not hasattr(p, 'vpset1'))
1781 # self.assert_(not hasattr(p, 'vpset2'))
1782 
1783  p = Process("test")
1784  p.a = EDAnalyzer("MyAnalyzer")
1785  p.b = EDAnalyzer("YourAnalyzer")
1786  p.c = EDAnalyzer("OurAnalyzer")
1787  p.d = EDAnalyzer("OurAnalyzer")
1788  p.e = EDAnalyzer("OurAnalyzer")
1789  p.s = Sequence(p.d)
1790  p.s2 = Sequence(p.b)
1791  p.s3 = Sequence(p.e)
1792  p.path1 = Path(p.a)
1793  p.path2 = Path(p.b)
1794  p.path3 = Path(p.b+p.s2)
1795  p.path4 = Path(p.b+p.s3)
1796  p.schedule = Schedule(p.path1,p.path2,p.path3)
1797  pths = p.paths
1798  keys = pths.keys()
1799  self.assertEqual(pths[keys[0]],p.path1)
1800  self.assertEqual(pths[keys[1]],p.path2)
1801  p.prune()
1802  self.assert_(hasattr(p, 'a'))
1803  self.assert_(hasattr(p, 'b'))
1804  self.assert_(not hasattr(p, 'c'))
1805  self.assert_(not hasattr(p, 'd'))
1806  self.assert_(not hasattr(p, 'e'))
1807  self.assert_(not hasattr(p, 's'))
1808  self.assert_(hasattr(p, 's2'))
1809  self.assert_(not hasattr(p, 's3'))
1810  self.assert_(hasattr(p, 'path1'))
1811  self.assert_(hasattr(p, 'path2'))
1812  self.assert_(hasattr(p, 'path3'))
1813  self.assert_(not hasattr(p, 'path4'))
1814  #test SequencePlaceholder
1815  p = Process("test")
1816  p.a = EDAnalyzer("MyAnalyzer")
1817  p.b = EDAnalyzer("YourAnalyzer")
1818  p.s = Sequence(SequencePlaceholder("a")+p.b)
1819  p.pth = Path(p.s)
1820  p.prune()
1821  self.assert_(hasattr(p, 'a'))
1822  self.assert_(hasattr(p, 'b'))
1823  self.assert_(hasattr(p, 's'))
self.assert_(hasattr(p, 'pth'))
def Config.TestModuleCommand.testRefToPSet (   self)

Definition at line 1735 of file Config.py.

1736  def testRefToPSet(self):
1737  proc = Process("test")
1738  proc.top = PSet(a = int32(1))
1739  proc.ref = PSet(refToPSet_ = string("top"))
1740  proc.ref2 = PSet( a = int32(1), b = PSet( refToPSet_ = string("top")))
1741  proc.ref3 = PSet(refToPSet_ = string("ref"))
1742  proc.ref4 = VPSet(PSet(refToPSet_ = string("top")),
1743  PSet(refToPSet_ = string("ref2")))
1744  p = TestMakePSet()
1745  proc.fillProcessDesc(p)
1746  self.assertEqual((True,1),p.values["ref"][1].values["a"])
1747  self.assertEqual((True,1),p.values["ref3"][1].values["a"])
1748  self.assertEqual((True,1),p.values["ref2"][1].values["a"])
1749  self.assertEqual((True,1),p.values["ref2"][1].values["b"][1].values["a"])
1750  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 1495 of file Config.py.

1496  def testSchedule(self):
1497  p = Process("test")
1498  p.a = EDAnalyzer("MyAnalyzer")
1499  p.b = EDAnalyzer("YourAnalyzer")
1500  p.c = EDAnalyzer("OurAnalyzer")
1501  p.d = EDAnalyzer("OurAnalyzer")
1502  p.path1 = Path(p.a)
1503  p.path2 = Path(p.b)
1504  p.path3 = Path(p.d)
1505 
1506  s = Schedule(p.path1,p.path2)
1507  self.assertEqual(s[0],p.path1)
1508  self.assertEqual(s[1],p.path2)
1509  p.schedule = s
1510  self.assert_('b' in p.schedule.moduleNames())
1511  self.assert_(hasattr(p, 'b'))
1512  self.assert_(hasattr(p, 'c'))
1513  self.assert_(hasattr(p, 'd'))
1514  self.assert_(hasattr(p, 'path1'))
1515  self.assert_(hasattr(p, 'path2'))
1516  self.assert_(hasattr(p, 'path3'))
1517  p.prune()
1518  self.assert_('b' in p.schedule.moduleNames())
1519  self.assert_(hasattr(p, 'b'))
1520  self.assert_(not hasattr(p, 'c'))
1521  self.assert_(not hasattr(p, 'd'))
1522  self.assert_(hasattr(p, 'path1'))
1523  self.assert_(hasattr(p, 'path2'))
1524  self.assert_(not hasattr(p, 'path3'))
1525 
1526  #adding a path not attached to the Process should cause an exception
1527  p = Process("test")
1528  p.a = EDAnalyzer("MyAnalyzer")
1529  path1 = Path(p.a)
1530  s = Schedule(path1)
1531  self.assertRaises(RuntimeError, lambda : p.setSchedule_(s) )
1532 
1533  #make sure anonymous sequences work
1534  p = Process("test")
1535  p.a = EDAnalyzer("MyAnalyzer")
1536  p.b = EDAnalyzer("MyOtherAnalyzer")
1537  p.c = EDProducer("MyProd")
1538  path1 = Path(p.c*Sequence(p.a+p.b))
1539  s = Schedule(path1)
1540  self.assert_('a' in s.moduleNames())
1541  self.assert_('b' in s.moduleNames())
1542  self.assert_('c' in s.moduleNames())
1543  p.path1 = path1
1544  p.schedule = s
1545  p.prune()
1546  self.assert_('a' in s.moduleNames())
1547  self.assert_('b' in s.moduleNames())
1548  self.assert_('c' in s.moduleNames())
def Config.TestModuleCommand.testSecSource (   self)

Definition at line 1417 of file Config.py.

References python.rootplot.root2matplotlib.replace().

1418  def testSecSource(self):
1419  p = Process('test')
1420  p.a = SecSource("MySecSource")
1421  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 1432 of file Config.py.

1433  def testSequence(self):
1434  p = Process('test')
1435  p.a = EDAnalyzer("MyAnalyzer")
1436  p.b = EDAnalyzer("YourAnalyzer")
1437  p.c = EDAnalyzer("OurAnalyzer")
1438  p.s = Sequence(p.a*p.b)
1439  self.assertEqual(str(p.s),'a+b')
1440  self.assertEqual(p.s.label_(),'s')
1441  path = Path(p.c+p.s)
1442  self.assertEqual(str(path),'c+a+b')
1443  p._validateSequence(path, 'p1')
1444  notInProcess = EDAnalyzer('NotInProcess')
1445  p2 = Path(p.c+p.s*notInProcess)
1446  self.assertRaises(RuntimeError, p._validateSequence, p2, 'p2')
def Config.TestModuleCommand.testSequence2 (   self)

Definition at line 1447 of file Config.py.

1448  def testSequence2(self):
1449  p = Process('test')
1450  p.a = EDAnalyzer("MyAnalyzer")
1451  p.b = EDAnalyzer("YourAnalyzer")
1452  p.c = EDAnalyzer("OurAnalyzer")
1453  testseq = Sequence(p.a*p.b)
1454  p.s = testseq
1455  #p.y = testseq
1456  self.assertRaises(ValueError, p.__setattr__, "y", testseq)
def Config.TestModuleCommand.testSubProcess (   self)

Definition at line 1696 of file Config.py.

References cond.hash.

1697  def testSubProcess(self):
1698  process = Process("Parent")
1699  subProcess = Process("Child")
1700  subProcess.a = EDProducer("A")
1701  subProcess.p = Path(subProcess.a)
1702  subProcess.add_(Service("Foo"))
1703  process.add_( SubProcess(subProcess) )
1704  d = process.dumpPython()
1705  equalD ="""import FWCore.ParameterSet.Config as cms
1706 
1707 process = cms.Process("Parent")
1708 
1709 parentProcess = process
1710 import FWCore.ParameterSet.Config as cms
1711 
1712 process = cms.Process("Child")
1713 
1714 process.a = cms.EDProducer("A")
1715 
1716 
1717 process.p = cms.Path(process.a)
1718 
1719 
1720 process.Foo = cms.Service("Foo")
1721 
1722 
1723 childProcess = process
1724 process = parentProcess
1725 process.subProcess = cms.SubProcess( process = childProcess, SelectEvents = cms.untracked.PSet(
1726 
1727 ), outputCommands = cms.untracked.vstring())
1728 """
1729  equalD = equalD.replace("parentProcess","parentProcess"+str(hash(process.subProcess)))
1730  self.assertEqual(d,equalD)
1731  p = TestMakePSet()
1732  process.subProcess.insertInto(p,"dummy")
1733  self.assertEqual((True,['a']),p.values["@sub_process"][1].values["process"][1].values['@all_modules'])
1734  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 1220 of file Config.py.

1221  def testTypedParameterizable(self):
1222  p = _TypedParameterizable("blah", b=int32(1))
1223  #see if copy works deeply
1224  other = p.copy()
1225  other.b = 2
1226  self.assertNotEqual(p.b,other.b)
def Config.TestModuleCommand.testUsing (   self)

Definition at line 1582 of file Config.py.

1583  def testUsing(self):
1584  p = Process('test')
1585  p.block = PSet(a = int32(1))
1586  p.modu = EDAnalyzer('Analyzer', p.block, b = int32(2))
1587  self.assertEqual(p.modu.a.value(),1)
1588  self.assertEqual(p.modu.b.value(),2)

Member Data Documentation

Config.TestModuleCommand.a

Definition at line 1859 of file Config.py.

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

Definition at line 1396 of file Config.py.

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

Definition at line 1389 of file Config.py.

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

Definition at line 1392 of file Config.py.