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 675 of file Mixins.py.

Member Function Documentation

def Mixins.testMixins.testClone (   self)

Definition at line 729 of file Mixins.py.

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

Definition at line 719 of file Mixins.py.

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

Definition at line 704 of file Mixins.py.

References resolutioncreator_cfi.object.

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

Definition at line 776 of file Mixins.py.

References Mixins.testMixins.tLPTest.

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

Definition at line 676 of file Mixins.py.

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

Definition at line 764 of file Mixins.py.

764  def testModified(self):
765  class __TestType(_SimpleParameterTypeBase):
766  def _isValid(self,value):
767  return True
768  a = __TestType(1)
769  self.assertEqual(a.isModified(),False)
770  a.setValue(1)
771  self.assertEqual(a.isModified(),False)
772  a.setValue(2)
773  self.assertEqual(a.isModified(),True)
774  a.resetModified()
775  self.assertEqual(a.isModified(),False)
def testModified(self)
Definition: Mixins.py:764
def Mixins.testMixins.testUsingBlock (   self)

Definition at line 716 of file Mixins.py.

716  def testUsingBlock(self):
717  a = UsingBlock("a")
718  self.assert_(isinstance(a, _ParameterTypeBase))
def testUsingBlock(self)
Definition: Mixins.py:716

Member Data Documentation

Mixins.testMixins.TestList

Definition at line 713 of file Mixins.py.

Mixins.testMixins.tLPTest

Definition at line 784 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

Mixins.testMixins.tLPTestType

Definition at line 785 of file Mixins.py.