Skip to content

Commit

Permalink
Add tests for the type ambiguity case in allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Aug 15, 2019
1 parent 6d02611 commit ea8bf89
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions FWCore/ParameterSet/python/Types.py
Expand Up @@ -1690,6 +1690,30 @@ def testAllowed(self):
p2.aValue = PSet(i = int32(3))
self.assertEqual(p2.aValue.i.value(),3)

p3 = PSet(aValue=required.allowed(int32,uint32))
p3.aValue = -42
self.assertEqual(p3.aValue.value(), -42)
p3 = PSet(aValue=required.allowed(int32,uint32))
self.assertRaises(RuntimeError, lambda: setattr(p3, "aValue", 42))

p3 = PSet(aValue=required.untracked.allowed(int32,uint32))
p3.aValue = -42
self.assertEqual(p3.aValue.value(), -42)
p3 = PSet(aValue=required.untracked.allowed(int32,uint32))
self.assertRaises(RuntimeError, lambda: setattr(p3, "aValue", 42))

p3 = PSet(aValue=optional.allowed(int32,uint32))
p3.aValue = -42
self.assertEqual(p3.aValue.value(), -42)
p3 = PSet(aValue=optional.allowed(int32,uint32))
self.assertRaises(RuntimeError, lambda: setattr(p3, "aValue", 42))

p3 = PSet(aValue=optional.untracked.allowed(int32,uint32))
p3.aValue = -42
self.assertEqual(p3.aValue.value(), -42)
p3 = PSet(aValue=optional.untracked.allowed(int32,uint32))
self.assertRaises(RuntimeError, lambda: setattr(p3, "aValue", 42))

def testVPSet(self):
p1 = VPSet(PSet(anInt = int32(1)), PSet(anInt=int32(2)))
self.assertEqual(len(p1),2)
Expand Down

0 comments on commit ea8bf89

Please sign in to comment.