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

Member Function Documentation

def Mixins.testMixins.testClone (   self)

Definition at line 731 of file Mixins.py.

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

Definition at line 721 of file Mixins.py.

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

Definition at line 706 of file Mixins.py.

References resolutioncreator_cfi.object.

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

Definition at line 778 of file Mixins.py.

References Mixins.testMixins.tLPTest.

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

Definition at line 678 of file Mixins.py.

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

Definition at line 766 of file Mixins.py.

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

Definition at line 718 of file Mixins.py.

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

Member Data Documentation

Mixins.testMixins.TestList

Definition at line 715 of file Mixins.py.

Mixins.testMixins.tLPTest

Definition at line 786 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

Mixins.testMixins.tLPTestType

Definition at line 787 of file Mixins.py.