CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
Mixins.testMixins Class Reference
Inheritance diagram for Mixins.testMixins:

Public Member Functions

def testClone (self)
 
def testCopy (self)
 
def testLargeList (self)
 
def testLargeParameterizable (self)
 
def testListConstruction (self)
 
def testModified (self)
 
def testUsingBlock (self)
 

Public Attributes

 TestList
 
 tLPTest
 
 tLPTestType
 

Detailed Description

Definition at line 679 of file Mixins.py.

Member Function Documentation

def Mixins.testMixins.testClone (   self)

Definition at line 733 of file Mixins.py.

733  def testClone(self):
734  class __Test(_TypedParameterizable):
735  pass
736  class __TestType(_SimpleParameterTypeBase):
737  def _isValid(self,value):
738  return True
739  class __PSet(_ParameterTypeBase,_Parameterizable):
740  def __init__(self,*arg,**args):
741  #need to call the inits separately
742  _ParameterTypeBase.__init__(self)
743  _Parameterizable.__init__(self,*arg,**args)
744  a = __Test("MyType",
745  t=__TestType(1),
746  u=__TestType(2),
747  w = __TestType(3),
748  x = __PSet(a = __TestType(4),
749  b = __TestType(6),
750  c = __PSet(gamma = __TestType(5))))
751  b = a.clone(t=3,
752  v=__TestType(4),
753  w= None,
754  x = dict(a = 7,
755  c = dict(gamma = 8),
756  d = __TestType(9)))
757  c = a.clone(x = dict(a=None, c=None))
758  self.assertEqual(a.t.value(),1)
759  self.assertEqual(a.u.value(),2)
760  self.assertEqual(b.t.value(),3)
761  self.assertEqual(b.u.value(),2)
762  self.assertEqual(b.v.value(),4)
763  self.assertEqual(b.x.a.value(),7)
764  self.assertEqual(b.x.b.value(),6)
765  self.assertEqual(b.x.c.gamma.value(),8)
766  self.assertEqual(b.x.d.value(),9)
767  self.assertEqual(hasattr(b,"w"), False)
768  self.assertEqual(hasattr(c.x,"a"), False)
769  self.assertEqual(hasattr(c.x,"c"), False)
770  self.assertRaises(TypeError,a.clone,None,**{"v":1})
def testClone(self)
Definition: Mixins.py:733
def Mixins.testMixins.testCopy (   self)

Definition at line 723 of file Mixins.py.

723  def testCopy(self):
724  class __Test(_TypedParameterizable):
725  pass
726  class __TestType(_SimpleParameterTypeBase):
727  def _isValid(self,value):
728  return True
729  a = __Test("MyType",t=__TestType(1), u=__TestType(2))
730  b = a.copy()
731  self.assertEqual(b.t.value(),1)
732  self.assertEqual(b.u.value(),2)
def testCopy(self)
Definition: Mixins.py:723
def Mixins.testMixins.testLargeList (   self)

Definition at line 708 of file Mixins.py.

References resolutioncreator_cfi.object.

708  def testLargeList(self):
709  #lists larger than 255 entries can not be initialized
710  #using the constructor
711  args = [i for i in xrange(0,300)]
712 
713  t = TestList(*args)
714  pdump= t.dumpPython()
715  class cms(object):
716  def __init__(self):
717  self.TestList = TestList
718  pythonized = eval( pdump, globals(),{'cms':cms()} )
719  self.assertEqual(t,pythonized)
def testLargeList(self)
Definition: Mixins.py:708
def Mixins.testMixins.testLargeParameterizable (   self)

Definition at line 783 of file Mixins.py.

References Mixins.testMixins.tLPTest.

785  pass
787  def _isValid(self,value):
788  return True
789  class __DummyModule(object):
790  def __init__(self):
791  self.tLPTest = tLPTest
792  self.tLPTestType = tLPTestType
793  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in xrange(0,300) ] ) )
794  #check they are the same
795  self.assertEqual(p.dumpPython(), eval(p.dumpPython(),{"cms": __DummyModule()}).dumpPython())
796  unittest.main()
def testLargeParameterizable(self)
Definition: Mixins.py:783
def dumpPython(process, name)
def Mixins.testMixins.testListConstruction (   self)

Definition at line 680 of file Mixins.py.

681  t = TestList(1)
682  self.assertEqual(t,[1])
683  t = TestList((1,))
684  self.assertEqual(t,[1])
685  t = TestList("one")
686  self.assertEqual(t,["one"])
687  t = TestList( [1,])
688  self.assertEqual(t,[1])
689  t = TestList( (x for x in [1]) )
690  self.assertEqual(t,[1])
691 
692  t = TestList(1,2)
693  self.assertEqual(t,[1,2])
694  t = TestList((1,2))
695  self.assertEqual(t,[1,2])
696  t = TestList("one","two")
697  self.assertEqual(t,["one","two"])
698  t = TestList(("one","two"))
699  self.assertEqual(t,["one","two"])
700  t = TestList( [1,2])
701  self.assertEqual(t,[1,2])
702  t = TestList( (x for x in [1,2]) )
703  self.assertEqual(t,[1,2])
704  t = TestList( iter((1,2)) )
705  self.assertEqual(t,[1,2])
706 
707 
def testListConstruction(self)
Definition: Mixins.py:680
def Mixins.testMixins.testModified (   self)

Definition at line 771 of file Mixins.py.

771  def testModified(self):
772  class __TestType(_SimpleParameterTypeBase):
773  def _isValid(self,value):
774  return True
775  a = __TestType(1)
776  self.assertEqual(a.isModified(),False)
777  a.setValue(1)
778  self.assertEqual(a.isModified(),False)
779  a.setValue(2)
780  self.assertEqual(a.isModified(),True)
781  a.resetModified()
782  self.assertEqual(a.isModified(),False)
def testModified(self)
Definition: Mixins.py:771
def Mixins.testMixins.testUsingBlock (   self)

Definition at line 720 of file Mixins.py.

720  def testUsingBlock(self):
721  a = UsingBlock("a")
722  self.assert_(isinstance(a, _ParameterTypeBase))
def testUsingBlock(self)
Definition: Mixins.py:720

Member Data Documentation

Mixins.testMixins.TestList

Definition at line 717 of file Mixins.py.

Mixins.testMixins.tLPTest

Definition at line 791 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

Mixins.testMixins.tLPTestType

Definition at line 792 of file Mixins.py.