Skip to content

Commit

Permalink
Fix unit tests python 3
Browse files Browse the repository at this point in the history
Changes in Config.py are only reordering things
  • Loading branch information
makortel committed Jul 15, 2021
1 parent c84edd7 commit 2f66ff8
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 90 deletions.
28 changes: 14 additions & 14 deletions FWCore/ParameterSet/python/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2431,13 +2431,13 @@ def testTask(self):
# Also note that the mutating visitor replaces sequences and tasks that have
# modified contents with their modified contents, it does not modify the sequence
# or task itself.
self.assertTrue(process.path21.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
self.assertTrue(process.path21.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.sequence3, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.d, process.mesproducer, process.messource, process.mfilter, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')

process.path22 = process.path21.copyAndExclude([process.d, process.mesproducer, process.mfilter])
self.assertTrue(process.path22.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.messource, process.mproducer10, process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
self.assertTrue(process.path22.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer10+process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None, process.mproducer10), cms.Task(process.messource, process.mproducer10, process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')

process.path23 = process.path22.copyAndExclude([process.messource, process.mproducer10])
self.assertTrue(process.path23.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None), cms.Task(process.mproducer2, process.myTask6), process.myTask100, process.myTask5)\n')
self.assertTrue(process.path23.dumpPython(PrintOptions()) == 'cms.Path(process.mproducer8+process.mproducer8+(process.mproducer8+process.mproducer9)+process.mproducer8, cms.Task(), cms.Task(process.None), cms.Task(process.mproducer2, process.mproducer8, process.myTask5), process.myTask100, process.myTask5)\n')

process.a = EDAnalyzer("MyAnalyzer")
process.b = OutputModule("MyOutputModule")
Expand Down Expand Up @@ -3116,14 +3116,14 @@ def testTaskPlaceholder(self):
process.i = cms.EDProducer("mi")
process.j = cms.EDProducer("mj")
process.b = cms.EDAnalyzer("mb")
process.t8 = cms.Task(cms.TaskPlaceholder("j"))
process.t6 = cms.Task(cms.TaskPlaceholder("h"))
process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6)
process.t4 = cms.Task(cms.TaskPlaceholder("f"))
process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a)
process.t3 = cms.Task(cms.TaskPlaceholder("e"))
process.t1 = cms.Task(cms.TaskPlaceholder("c"))
process.t2 = cms.Task(cms.TaskPlaceholder("d"), process.a, process.t1)
process.t3 = cms.Task(cms.TaskPlaceholder("e"))
process.t5 = cms.Task(cms.TaskPlaceholder("g"), cms.TaskPlaceholder("t4"), process.a)
process.t4 = cms.Task(cms.TaskPlaceholder("f"))
process.t6 = cms.Task(cms.TaskPlaceholder("h"))
process.t7 = cms.Task(cms.TaskPlaceholder("i"), process.a, process.t6)
process.t8 = cms.Task(cms.TaskPlaceholder("j"))
process.path1 = cms.Path(process.b, process.t2, process.t3)
process.endpath1 = cms.EndPath(process.b, process.t5)
process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
Expand All @@ -3139,14 +3139,14 @@ def testTaskPlaceholder(self):
process.i = cms.EDProducer("mi")
process.j = cms.EDProducer("mj")
process.b = cms.EDAnalyzer("mb")
process.t8 = cms.Task(process.j)
process.t1 = cms.Task(process.c)
process.t2 = cms.Task(process.a, process.d, process.t1)
process.t3 = cms.Task(process.e)
process.t4 = cms.Task(process.f)
process.t6 = cms.Task(process.h)
process.t7 = cms.Task(process.a, process.i, process.t6)
process.t4 = cms.Task(process.f)
process.t8 = cms.Task(process.j)
process.t5 = cms.Task(process.a, process.g, process.t4)
process.t3 = cms.Task(process.e)
process.t1 = cms.Task(process.c)
process.t2 = cms.Task(process.a, process.d, process.t1)
process.path1 = cms.Path(process.b, process.t2, process.t3)
process.endpath1 = cms.EndPath(process.b, process.t5)
process.schedule = cms.Schedule(*[ process.path1, process.endpath1 ], tasks=[process.t7, process.t8])""")
Expand Down
4 changes: 2 additions & 2 deletions FWCore/ParameterSet/python/DictTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ def __init__(self,*args,**kw):
dict.__init__(self,*args,**kw)
self.list = list()
if len(args) == 1:
if not hasattr(args[0],'iterkeys'):
if not hasattr(args[0],'keys'):
s = set()
#must protect against adding the same key multiple times
for x,y in iter(args[0]):
if x not in s:
self.list.append(x)
s.add(x)
else:
self.list = list(args[0].iterkeys())
self.list = list(args[0].keys())
return
self.list = list(six.iterkeys(super(SortedKeysDict,self)))

Expand Down
4 changes: 2 additions & 2 deletions FWCore/ParameterSet/python/Mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def __init__(self):
self.assertEqual(t,pythonized)
def testUsingBlock(self):
a = UsingBlock("a")
self.assert_(isinstance(a, _ParameterTypeBase))
self.assertTrue(isinstance(a, _ParameterTypeBase))
def testConstruction(self):
class __Test(_TypedParameterizable):
pass
Expand Down Expand Up @@ -929,7 +929,7 @@ def __init__(self):
def testSpecialImportRegistry(self):
reg = _SpecialImportRegistry()
reg.registerSpecialImportForType(int, "import foo")
self.assertRaises(lambda x: reg.registerSpecialImportForType(int, "import bar"))
self.assertRaises(RuntimeError, lambda: reg.registerSpecialImportForType(int, "import bar"))
reg.registerSpecialImportForType(str, "import bar")
self.assertEqual(reg.getSpecialImports(), [])
reg.registerUse([1])
Expand Down
31 changes: 13 additions & 18 deletions FWCore/ParameterSet/python/SequenceTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,12 @@ def _replaceIfHeldDirectly(self,original,replacement):
if original == i:
self._collection[self._collection.index(original)] = replacement
didReplace = True
elif isinstance(i,_UnarySequenceOperator):
if i._replace(original, replacement):
didReplace = True
if replacement is None:
self._collection[self._collection.index(i)] = None
elif isinstance(i,_UnarySequenceOperator) and i._has(original):
didReplace = True
if replacement is None:
self._collection[self._collection.index(i)] = None
else:
self._collection[self._collection.index(i)] = type(i)(replacement)
if replacement is None:
self._collection = [ i for i in self._collection if i is not None]
return didReplace
Expand Down Expand Up @@ -545,26 +546,20 @@ def __init__(self, operand):
raise RuntimeError("This operator cannot accept a non sequenceable type")
def __eq__(self, other):
# allows replace(~a, b)
return isinstance(self, type(other)) and self._operand==other._operand
return type(self) is type(other) and self._operand==other._operand
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
# this definition implies that self._operand MUST NOT be changed after the construction
return hash((type(self), self._operand))
def _findDependencies(self,knownDeps, presentDeps):
self._operand._findDependencies(knownDeps, presentDeps)
def _clonesequence(self, lookuptable):
return type(self)(self._operand._clonesequence(lookuptable))
def _replace(self, original, replacement):
if self._operand == original:
self._operand = replacement
return True
return False
def _remove(self, original):
if (self._operand == original): return (None, True)
(self._operand, found) = self._operand._remove(original)
if self._operand == None: return (None, True)
return (self, found)
def _has(self, op):
return self._operand == op
def resolve(self, processDict,keepIfCannotResolve=False):
self._operand = self._operand.resolve(processDict,keepIfCannotResolve)
return self
return type(self)(self._operand.resolve(processDict,keepIfCannotResolve))
def isOperation(self):
return True
def _visitSubNodes(self,visitor):
Expand Down
Loading

0 comments on commit 2f66ff8

Please sign in to comment.