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 testSpecialImportRegistry (self)
 
def testUsingBlock (self)
 

Public Attributes

 TestList
 
 tLPTest
 
 tLPTestType
 

Detailed Description

Definition at line 716 of file Mixins.py.

Member Function Documentation

def Mixins.testMixins.testClone (   self)

Definition at line 770 of file Mixins.py.

770  def testClone(self):
771  class __Test(_TypedParameterizable):
772  pass
773  class __TestType(_SimpleParameterTypeBase):
774  def _isValid(self,value):
775  return True
776  class __PSet(_ParameterTypeBase,_Parameterizable):
777  def __init__(self,*arg,**args):
778  #need to call the inits separately
779  _ParameterTypeBase.__init__(self)
780  _Parameterizable.__init__(self,*arg,**args)
781  a = __Test("MyType",
782  t=__TestType(1),
783  u=__TestType(2),
784  w = __TestType(3),
785  x = __PSet(a = __TestType(4),
786  b = __TestType(6),
787  c = __PSet(gamma = __TestType(5))))
788  b = a.clone(t=3,
789  v=__TestType(4),
790  w= None,
791  x = dict(a = 7,
792  c = dict(gamma = 8),
793  d = __TestType(9)))
794  c = a.clone(x = dict(a=None, c=None))
795  self.assertEqual(a.t.value(),1)
796  self.assertEqual(a.u.value(),2)
797  self.assertEqual(b.t.value(),3)
798  self.assertEqual(b.u.value(),2)
799  self.assertEqual(b.v.value(),4)
800  self.assertEqual(b.x.a.value(),7)
801  self.assertEqual(b.x.b.value(),6)
802  self.assertEqual(b.x.c.gamma.value(),8)
803  self.assertEqual(b.x.d.value(),9)
804  self.assertEqual(hasattr(b,"w"), False)
805  self.assertEqual(hasattr(c.x,"a"), False)
806  self.assertEqual(hasattr(c.x,"c"), False)
807  self.assertRaises(TypeError,a.clone,None,**{"v":1})
def testClone(self)
Definition: Mixins.py:770
def Mixins.testMixins.testCopy (   self)

Definition at line 760 of file Mixins.py.

760  def testCopy(self):
761  class __Test(_TypedParameterizable):
762  pass
763  class __TestType(_SimpleParameterTypeBase):
764  def _isValid(self,value):
765  return True
766  a = __Test("MyType",t=__TestType(1), u=__TestType(2))
767  b = a.copy()
768  self.assertEqual(b.t.value(),1)
769  self.assertEqual(b.u.value(),2)
def testCopy(self)
Definition: Mixins.py:760
def Mixins.testMixins.testLargeList (   self)

Definition at line 745 of file Mixins.py.

References resolutioncreator_cfi.object.

745  def testLargeList(self):
746  #lists larger than 255 entries can not be initialized
747  #using the constructor
748  args = [i for i in range(0,300)]
749 
750  t = TestList(*args)
751  pdump= t.dumpPython()
752  class cms(object):
753  def __init__(self):
754  self.TestList = TestList
755  pythonized = eval( pdump, globals(),{'cms':cms()} )
756  self.assertEqual(t,pythonized)
Namespace of DDCMS conversion namespace.
def testLargeList(self)
Definition: Mixins.py:745
def Mixins.testMixins.testLargeParameterizable (   self)

Definition at line 820 of file Mixins.py.

References Mixins.testMixins.tLPTest.

822  pass
824  def _isValid(self,value):
825  return True
826  class __DummyModule(object):
827  def __init__(self):
828  self.tLPTest = tLPTest
829  self.tLPTestType = tLPTestType
830  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) )
831  #check they are the same
832  self.assertEqual(p.dumpPython(), eval(p.dumpPython(),{"cms": __DummyModule()}).dumpPython())
def testLargeParameterizable(self)
Definition: Mixins.py:820
def dumpPython(process, name)
#define str(s)
def Mixins.testMixins.testListConstruction (   self)

Definition at line 717 of file Mixins.py.

718  t = TestList(1)
719  self.assertEqual(t,[1])
720  t = TestList((1,))
721  self.assertEqual(t,[1])
722  t = TestList("one")
723  self.assertEqual(t,["one"])
724  t = TestList( [1,])
725  self.assertEqual(t,[1])
726  t = TestList( (x for x in [1]) )
727  self.assertEqual(t,[1])
728 
729  t = TestList(1,2)
730  self.assertEqual(t,[1,2])
731  t = TestList((1,2))
732  self.assertEqual(t,[1,2])
733  t = TestList("one","two")
734  self.assertEqual(t,["one","two"])
735  t = TestList(("one","two"))
736  self.assertEqual(t,["one","two"])
737  t = TestList( [1,2])
738  self.assertEqual(t,[1,2])
739  t = TestList( (x for x in [1,2]) )
740  self.assertEqual(t,[1,2])
741  t = TestList( iter((1,2)) )
742  self.assertEqual(t,[1,2])
743 
744 
def testListConstruction(self)
Definition: Mixins.py:717
def Mixins.testMixins.testModified (   self)

Definition at line 808 of file Mixins.py.

808  def testModified(self):
809  class __TestType(_SimpleParameterTypeBase):
810  def _isValid(self,value):
811  return True
812  a = __TestType(1)
813  self.assertEqual(a.isModified(),False)
814  a.setValue(1)
815  self.assertEqual(a.isModified(),False)
816  a.setValue(2)
817  self.assertEqual(a.isModified(),True)
818  a.resetModified()
819  self.assertEqual(a.isModified(),False)
def testModified(self)
Definition: Mixins.py:808
def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 833 of file Mixins.py.

834  reg = _SpecialImportRegistry()
835  reg.registerSpecialImportForType(int, "import foo")
836  self.assertRaises(lambda x: reg.registerSpecialImportForType(int, "import bar"))
837  reg.registerSpecialImportForType(str, "import bar")
838  self.assertEqual(reg.getSpecialImports(), [])
839  reg.registerUse([1])
840  self.assertEqual(reg.getSpecialImports(), [])
841  reg.registerUse(1)
842  self.assertEqual(reg.getSpecialImports(), ["import foo"])
843  reg.registerUse(1)
844  self.assertEqual(reg.getSpecialImports(), ["import foo"])
845  reg.registerUse("a")
846  self.assertEqual(reg.getSpecialImports(), ["import bar", "import foo"])
847 
848  unittest.main()
def testSpecialImportRegistry(self)
Definition: Mixins.py:833
def Mixins.testMixins.testUsingBlock (   self)

Definition at line 757 of file Mixins.py.

757  def testUsingBlock(self):
758  a = UsingBlock("a")
759  self.assert_(isinstance(a, _ParameterTypeBase))
def testUsingBlock(self)
Definition: Mixins.py:757

Member Data Documentation

Mixins.testMixins.TestList

Definition at line 754 of file Mixins.py.

Mixins.testMixins.tLPTest

Definition at line 828 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

Mixins.testMixins.tLPTestType

Definition at line 829 of file Mixins.py.