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

Member Function Documentation

def Mixins.testMixins.testClone (   self)

Definition at line 735 of file Mixins.py.

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

Definition at line 725 of file Mixins.py.

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

Definition at line 710 of file Mixins.py.

References resolutioncreator_cfi.object.

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

Definition at line 785 of file Mixins.py.

References Mixins.testMixins.tLPTest.

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

Definition at line 682 of file Mixins.py.

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

Definition at line 773 of file Mixins.py.

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

Definition at line 722 of file Mixins.py.

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

Member Data Documentation

Mixins.testMixins.TestList

Definition at line 719 of file Mixins.py.

Mixins.testMixins.tLPTest

Definition at line 793 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

Mixins.testMixins.tLPTestType

Definition at line 794 of file Mixins.py.