CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
Mixins.testMixins Class Reference
Inheritance diagram for Mixins.testMixins:

Public Member Functions

def testClone
 
def testCopy
 
def testLargeList
 
def testLargeParameterizable
 
def testListConstruction
 
def testModified
 
def testUsingBlock
 

Public Attributes

 TestList
 
 tLPTest
 
 tLPTestType
 

Detailed Description

Definition at line 648 of file Mixins.py.

Member Function Documentation

def Mixins.testMixins.testClone (   self)

Definition at line 702 of file Mixins.py.

703  def testClone(self):
704  class __Test(_TypedParameterizable):
705  pass
706  class __TestType(_SimpleParameterTypeBase):
707  def _isValid(self,value):
708  return True
709  class __PSet(_ParameterTypeBase,_Parameterizable):
710  def __init__(self,*arg,**args):
711  #need to call the inits separately
712  _ParameterTypeBase.__init__(self)
713  _Parameterizable.__init__(self,*arg,**args)
714  a = __Test("MyType",
715  t=__TestType(1),
716  u=__TestType(2),
717  w = __TestType(3),
718  x = __PSet(a = __TestType(4),
719  b = __TestType(6),
720  c = __PSet(gamma = __TestType(5))))
721  b = a.clone(t=3,
722  v=__TestType(4),
723  w= None,
724  x = dict(a = 7,
725  c = dict(gamma = 8),
726  d = __TestType(9)))
727  self.assertEqual(a.t.value(),1)
728  self.assertEqual(a.u.value(),2)
729  self.assertEqual(b.t.value(),3)
730  self.assertEqual(b.u.value(),2)
731  self.assertEqual(b.v.value(),4)
732  self.assertEqual(b.x.a.value(),7)
733  self.assertEqual(b.x.b.value(),6)
734  self.assertEqual(b.x.c.gamma.value(),8)
735  self.assertEqual(b.x.d.value(),9)
736  self.assertEqual(hasattr(b,"w"), False)
self.assertRaises(TypeError,a.clone,None,**{"v":1})
def Mixins.testMixins.testCopy (   self)

Definition at line 692 of file Mixins.py.

693  def testCopy(self):
694  class __Test(_TypedParameterizable):
695  pass
696  class __TestType(_SimpleParameterTypeBase):
697  def _isValid(self,value):
698  return True
699  a = __Test("MyType",t=__TestType(1), u=__TestType(2))
700  b = a.copy()
701  self.assertEqual(b.t.value(),1)
self.assertEqual(b.u.value(),2)
def Mixins.testMixins.testLargeList (   self)

Definition at line 677 of file Mixins.py.

678  def testLargeList(self):
679  #lists larger than 255 entries can not be initialized
680  #using the constructor
681  args = [i for i in xrange(0,300)]
682 
683  t = TestList(*args)
684  pdump= t.dumpPython()
685  class cms(object):
686  def __init__(self):
687  self.TestList = TestList
688  pythonized = eval( pdump, globals(),{'cms':cms()} )
self.assertEqual(t,pythonized)
def Mixins.testMixins.testLargeParameterizable (   self)

Definition at line 749 of file Mixins.py.

References Mixins.testMixins.tLPTest.

750  def testLargeParameterizable(self):
752  pass
754  def _isValid(self,value):
755  return True
756  class __DummyModule(object):
757  def __init__(self):
758  self.tLPTest = tLPTest
759  self.tLPTestType = tLPTestType
760  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in xrange(0,300) ] ) )
761  #check they are the same
762  self.assertEqual(p.dumpPython(), eval(p.dumpPython(),{"cms": __DummyModule()}).dumpPython())
unittest.main()
def testLargeParameterizable
Definition: Mixins.py:749
def Mixins.testMixins.testListConstruction (   self)

Definition at line 649 of file Mixins.py.

650  def testListConstruction(self):
651  t = TestList(1)
652  self.assertEqual(t,[1])
653  t = TestList((1,))
654  self.assertEqual(t,[1])
655  t = TestList("one")
656  self.assertEqual(t,["one"])
657  t = TestList( [1,])
658  self.assertEqual(t,[1])
659  t = TestList( (x for x in [1]) )
660  self.assertEqual(t,[1])
661 
662  t = TestList(1,2)
663  self.assertEqual(t,[1,2])
664  t = TestList((1,2))
665  self.assertEqual(t,[1,2])
666  t = TestList("one","two")
667  self.assertEqual(t,["one","two"])
668  t = TestList(("one","two"))
669  self.assertEqual(t,["one","two"])
670  t = TestList( [1,2])
671  self.assertEqual(t,[1,2])
672  t = TestList( (x for x in [1,2]) )
673  self.assertEqual(t,[1,2])
674  t = TestList( iter((1,2)) )
675  self.assertEqual(t,[1,2])
676 
def testListConstruction
Definition: Mixins.py:649
def Mixins.testMixins.testModified (   self)

Definition at line 737 of file Mixins.py.

738  def testModified(self):
739  class __TestType(_SimpleParameterTypeBase):
740  def _isValid(self,value):
741  return True
742  a = __TestType(1)
743  self.assertEqual(a.isModified(),False)
744  a.setValue(1)
745  self.assertEqual(a.isModified(),False)
746  a.setValue(2)
747  self.assertEqual(a.isModified(),True)
748  a.resetModified()
self.assertEqual(a.isModified(),False)
def Mixins.testMixins.testUsingBlock (   self)

Definition at line 689 of file Mixins.py.

690  def testUsingBlock(self):
691  a = UsingBlock("a")
self.assert_(isinstance(a, _ParameterTypeBase))
def testUsingBlock
Definition: Mixins.py:689

Member Data Documentation

Mixins.testMixins.TestList

Definition at line 686 of file Mixins.py.

Mixins.testMixins.tLPTest

Definition at line 757 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

Mixins.testMixins.tLPTestType

Definition at line 758 of file Mixins.py.