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

Member Function Documentation

def Mixins.testMixins.testClone (   self)

Definition at line 734 of file Mixins.py.

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

Definition at line 724 of file Mixins.py.

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

Definition at line 709 of file Mixins.py.

References resolutioncreator_cfi.object.

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

Definition at line 784 of file Mixins.py.

References Mixins.testMixins.tLPTest.

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

Definition at line 681 of file Mixins.py.

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

Definition at line 772 of file Mixins.py.

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

Definition at line 721 of file Mixins.py.

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

Member Data Documentation

Mixins.testMixins.TestList

Definition at line 718 of file Mixins.py.

Mixins.testMixins.tLPTest

Definition at line 792 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

Mixins.testMixins.tLPTestType

Definition at line 793 of file Mixins.py.