3065 m1.toModify(p.a,_mod_fred)
3066 self.assertEqual(p.a.fred.value(),2)
3068 m1.toModify(p.b, wilma = 2)
3069 self.assertEqual(p.b.wilma.value(),2)
3070 self.assert_(p.isUsingModifier(m1))
3075 m1.toModify(p.a,_mod_fred)
3077 m1.toModify(p.b, wilma = 2)
3078 self.assertEqual(p.a.fred.value(),1)
3079 self.assertEqual(p.b.wilma.value(),1)
3080 self.assertEqual(p.isUsingModifier(m1),
False)
3085 m1.toModify(p.a, fred =
int32(2))
3086 p.b = p.a.clone(wilma =
int32(3))
3087 self.assertEqual(p.a.fred.value(),2)
3088 self.assertEqual(p.a.wilma.value(),1)
3089 self.assertEqual(p.b.fred.value(),2)
3090 self.assertEqual(p.b.wilma.value(),3)
3095 m1.toModify(p.a, fred =
None, fintstones =
dict(fred =
None))
3096 self.assertEqual(hasattr(p.a,
"fred"),
False)
3097 self.assertEqual(hasattr(p.a.fintstones,
"fred"),
False)
3098 self.assertEqual(p.a.wilma.value(),1)
3103 m1.toModify(p.a, wilma =
int32(2))
3104 self.assertEqual(p.a.fred.value(), 1)
3105 self.assertEqual(p.a.wilma.value(),2)
3110 m1.toModify(p.a, flintstones =
dict(fred =
int32(2)))
3111 self.assertEqual(p.a.flintstones.fred.value(),2)
3112 self.assertEqual(p.a.flintstones.wilma.value(),1)
3117 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, flintstones =
dict(imnothere =
dict(wilma=2))))
3118 self.assertRaises(KeyError,
lambda: m1.toModify(p.a, foo = 1))
3123 m1.toModify(p.a, flintstones = {1:
dict(wilma =
int32(2))})
3124 self.assertEqual(p.a.flintstones[0].fred.value(),1)
3125 self.assertEqual(p.a.flintstones[1].wilma.value(),2)
3130 m1.toModify(p.a, fred = {1:7})
3131 self.assertEqual(p.a.fred[0],1)
3132 self.assertEqual(p.a.fred[1],7)
3133 self.assertEqual(p.a.fred[2],3)
3139 try: m1.toModify(p.a, fred = {5:7})
3140 except IndexError
as e: raised =
True 3141 self.assertEqual(raised,
True)
3147 try: m1.toModify(p.a, flintstones =
dict(bogus =
int32(37)))
3148 except TypeError
as e: raised =
True 3149 self.assertEqual(raised,
True)
3153 class ProcModifierMod(
object):
3154 def __init__(self,modifier,func):
3159 testMod = DummyMod()
3161 self.assert_(hasattr(p,
"a"))
3164 testProcMod = ProcModifierMod(m1,_rem_a)
3166 p.extend(testProcMod)
3167 self.assert_(
not hasattr(p,
"a"))
3172 self.assert_(p.isUsingModifier(m1))
3173 self.assert_(p.isUsingModifier(mc))
3174 testMod = DummyMod()
3176 m1.toModify(p.b, fred =
int32(3))
3178 testProcMod = ProcModifierMod(m1,_rem_a)
3179 p.extend(testProcMod)
3180 self.assert_(
not hasattr(p,
"a"))
3181 self.assertEqual(p.b.fred.value(),3)
3186 mclone = mc.copyAndExclude([m2])
3187 self.assert_(
not mclone._isOrContains(m2))
3188 self.assert_(mclone._isOrContains(m1))
3191 mclone = mc2.copyAndExclude([m2])
3192 self.assert_(
not mclone._isOrContains(m2))
3193 self.assert_(mclone._isOrContains(m1))
3194 self.assert_(mclone._isOrContains(m3))
3200 (m1 & m2).toModify(p.a, fred =
int32(2))
3201 self.assertRaises(TypeError,
lambda: (m1 & m2).toModify(p.a, 1, wilma=2))
3202 self.assertEqual(p.a.fred, 1)
3207 (m1 & m2).toModify(p.a, fred =
int32(2))
3208 self.assertEqual(p.a.fred, 2)
3214 (m1 & m2 & m3).toModify(p.a, fred =
int32(2))
3215 self.assertEqual(p.a.fred, 2)
3216 (m1 & (m2 & m3)).toModify(p.a, fred =
int32(3))
3217 self.assertEqual(p.a.fred, 3)
3218 ((m1 & m2) & m3).toModify(p.a, fred =
int32(4))
3219 self.assertEqual(p.a.fred, 4)
3225 (~m1).toModify(p.a, fred=2)
3226 self.assertEqual(p.a.fred, 1)
3227 (~m2).toModify(p.a, wilma=2)
3228 self.assertEqual(p.a.wilma, 2)
3229 self.assertRaises(TypeError,
lambda: (~m1).toModify(p.a, 1, wilma=2))
3230 self.assertRaises(TypeError,
lambda: (~m2).toModify(p.a, 1, wilma=2))
3237 (m1 | m2).toModify(p.a, fred=2)
3238 self.assertEqual(p.a.fred, 2)
3239 (m1 | m2 | m3).toModify(p.a, fred=3)
3240 self.assertEqual(p.a.fred, 3)
3241 (m3 | m2 | m1).toModify(p.a, fred=4)
3242 self.assertEqual(p.a.fred, 4)
3243 ((m1 | m2) | m3).toModify(p.a, fred=5)
3244 self.assertEqual(p.a.fred, 5)
3245 (m1 | (m2 | m3)).toModify(p.a, fred=6)
3246 self.assertEqual(p.a.fred, 6)
3247 (m2 | m3).toModify(p.a, fred=7)
3248 self.assertEqual(p.a.fred, 6)
3249 self.assertRaises(TypeError,
lambda: (m1 | m2).toModify(p.a, 1, wilma=2))
3250 self.assertRaises(TypeError,
lambda: (m2 | m3).toModify(p.a, 1, wilma=2))
3258 (m1 & ~m2).toModify(p.a, fred=2)
3259 self.assertEqual(p.a.fred, 1)
3260 (m1 & ~m3).toModify(p.a, fred=2)
3261 self.assertEqual(p.a.fred, 2)
3262 (m1 | ~m2).toModify(p.a, fred=3)
3263 self.assertEqual(p.a.fred, 3)
3264 (~m1 | ~m2).toModify(p.a, fred=4)
3265 self.assertEqual(p.a.fred, 3)
3266 (~m3 & ~m4).toModify(p.a, fred=4)
3267 self.assertEqual(p.a.fred, 4)
3268 ((m1 & m3) | ~m4).toModify(p.a, fred=5)
3269 self.assertEqual(p.a.fred, 5)
3275 self.assertRaises(TypeError,
lambda: m1.toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3282 m1.toReplaceWith(p.s,
Sequence(p.a+p.b, p.td))
3283 self.assertEqual(p.a.wilma.value(),3)
3284 self.assertEqual(p.a.type_(),
"YourAnalyzer")
3285 self.assertEqual(hasattr(p,
"fred"),
False)
3286 self.assertTrue(p.s.dumpPython(
"") ==
"cms.Sequence(process.a+process.b, process.td)\n")
3288 m1.toReplaceWith(p.td,
Task(p.e))
3289 self.assertTrue(p.td._collection ==
OrderedSet([p.e]))
3295 self.assertEqual(p.a.type_(),
"MyAnalyzer")
3303 self.assertRaises(TypeError,
lambda: (m1 & m2).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3304 self.assertRaises(TypeError,
lambda: (m3 & m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3305 self.assertRaises(TypeError,
lambda: (~m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3306 self.assertRaises(TypeError,
lambda: (~m1).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3307 self.assertRaises(TypeError,
lambda: (m1 | m3).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3308 self.assertRaises(TypeError,
lambda: (m3 | m4).toReplaceWith(p.a,
EDProducer(
"YourProducer")))
3309 (m1 & m2).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer1"))
3310 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3311 (m1 & m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3312 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3313 (~m1).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3314 self.assertEqual(p.a.type_(),
"YourAnalyzer1")
3315 (~m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer2"))
3316 self.assertEqual(p.a.type_(),
"YourAnalyzer2")
3317 (m1 | m3).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer3"))
3318 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3319 (m3 | m4).toReplaceWith(p.a,
EDAnalyzer(
"YourAnalyzer4"))
3320 self.assertEqual(p.a.type_(),
"YourAnalyzer3")
3327 m.toModify(a, foo2 = {0:
dict(type =
"Foo3")})
3328 self.assertEqual(a.foo2[0].type,
"Foo3")
3331 self.assertEqual(a.foo2[0].type,
"Foo3")
3332 self.assertEqual(a.foo4[0].type,
"Foo4")
3334 m.toModify(a, foo2 =
None)
3335 self.assertFalse(hasattr(a,
"foo2"))
3336 self.assertEqual(a.foo4[0].type,
"Foo4")
3339 self.assertFalse(hasattr(a,
"foo2"))
3340 self.assertFalse(hasattr(a,
"foo4"))
3341 self.assertTrue(hasattr(a,
"bar"))
3342 self.assertEqual(a.bar[0].type,
"Bar")
3355 test1 =
dict(a = 4, b =
dict(c =
None)),
3357 self.assertEqual(sp.test1.a.value(), 4)
3358 self.assertEqual(sp.test1.b.hasParameter(
"c"),
False)
3359 self.assertEqual(sp.test2.aa.value(), 15)
3360 self.assertEqual(sp.test2.bb.cc.value(), 45)
3361 self.assertEqual(sp.test2.bb.dd.value(),
"foo")
3364 self.assertEqual(sp.test1.type_(),
"Fred")
3365 self.assertEqual(sp.test1.x.value(), 42)
3366 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test1,
EDAnalyzer(
"Foo")))
3369 self.assertEqual(sp.test2.type_(),
"Xyzzy")
3370 self.assertEqual(sp.test2.x.value(), 24)
3371 self.assertRaises(TypeError,
lambda: m.toModify(sp, test2 =
EDAnalyzer(
"Foo")))
3374 self.assertEqual(sp.test3.type_(),
"Wilma")
3375 self.assertEqual(sp.test3.y.value(), 24)
3376 self.assertRaises(TypeError,
lambda: m.toModify(sp, test4 =
EDAnalyzer(
"Foo")))
3378 m.toModify(sp, test2 =
None)
3379 self.assertEqual(hasattr(sp,
"test2"),
False)
3382 self.assertTrue(hasattr(sp.test2,
"foo"))
3385 self.assertTrue(hasattr(sp.test2,
"bar"))
3388 self.assertTrue(hasattr(sp.test2,
"xyzzy"))
3390 self.assertRaises(TypeError,
lambda: m.toReplaceWith(sp.test2,
EDProducer(
"Foo")))