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

Member Function Documentation

◆ testClone()

def Mixins.testMixins.testClone (   self)

Definition at line 808 of file Mixins.py.

808  def testClone(self):
809  class __Test(_TypedParameterizable):
810  pass
811  class __TestType(_SimpleParameterTypeBase):
812  def _isValid(self,value):
813  return True
814  class __PSet(_ParameterTypeBase,_Parameterizable):
815  def __init__(self,*arg,**args):
816  #need to call the inits separately
817  _ParameterTypeBase.__init__(self)
818  _Parameterizable.__init__(self,*arg,**args)
819  a = __Test("MyType",
820  t=__TestType(1),
821  u=__TestType(2),
822  w = __TestType(3),
823  x = __PSet(a = __TestType(4),
824  b = __TestType(6),
825  c = __PSet(gamma = __TestType(5))))
826  b = a.clone(t=3,
827  v=__TestType(4),
828  w= None,
829  x = dict(a = 7,
830  c = dict(gamma = 8),
831  d = __TestType(9)))
832  c = a.clone(x = dict(a=None, c=None))
833  self.assertEqual(a.t.value(),1)
834  self.assertEqual(a.u.value(),2)
835  self.assertEqual(b.t.value(),3)
836  self.assertEqual(b.u.value(),2)
837  self.assertEqual(b.v.value(),4)
838  self.assertEqual(b.x.a.value(),7)
839  self.assertEqual(b.x.b.value(),6)
840  self.assertEqual(b.x.c.gamma.value(),8)
841  self.assertEqual(b.x.d.value(),9)
842  self.assertEqual(hasattr(b,"w"), False)
843  self.assertEqual(hasattr(c.x,"a"), False)
844  self.assertEqual(hasattr(c.x,"c"), False)
845  self.assertRaises(TypeError,a.clone,None,**{"v":1})

◆ testCopy()

def Mixins.testMixins.testCopy (   self)

Definition at line 798 of file Mixins.py.

798  def testCopy(self):
799  class __Test(_TypedParameterizable):
800  pass
801  class __TestType(_SimpleParameterTypeBase):
802  def _isValid(self,value):
803  return True
804  a = __Test("MyType",t=__TestType(1), u=__TestType(2))
805  b = a.copy()
806  self.assertEqual(b.t.value(),1)
807  self.assertEqual(b.u.value(),2)

◆ testLargeList()

def Mixins.testMixins.testLargeList (   self)

Definition at line 783 of file Mixins.py.

783  def testLargeList(self):
784  #lists larger than 255 entries can not be initialized
785  #using the constructor
786  args = [i for i in range(0,300)]
787 
788  t = TestList(*args)
789  pdump= t.dumpPython()
790  class cms(object):
791  def __init__(self):
792  self.TestList = TestList
793  pythonized = eval( pdump, globals(),{'cms':cms()} )
794  self.assertEqual(t,pythonized)

References resolutioncreator_cfi.object, and FastTimerService_cff.range.

◆ testLargeParameterizable()

def Mixins.testMixins.testLargeParameterizable (   self)

Definition at line 858 of file Mixins.py.

858  def testLargeParameterizable(self):
859  class tLPTest(_TypedParameterizable):
860  pass
861  class tLPTestType(_SimpleParameterTypeBase):
862  def _isValid(self,value):
863  return True
864  class __DummyModule(object):
865  def __init__(self):
866  self.tLPTest = tLPTest
867  self.tLPTestType = tLPTestType
868  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) )
869  #check they are the same
870  self.assertEqual(p.dumpPython(), eval(p.dumpPython(),{"cms": __DummyModule()}).dumpPython())

References Mixins.testMixins.tLPTest.

◆ testListConstruction()

def Mixins.testMixins.testListConstruction (   self)

Definition at line 755 of file Mixins.py.

755  def testListConstruction(self):
756  t = TestList(1)
757  self.assertEqual(t,[1])
758  t = TestList((1,))
759  self.assertEqual(t,[1])
760  t = TestList("one")
761  self.assertEqual(t,["one"])
762  t = TestList( [1,])
763  self.assertEqual(t,[1])
764  t = TestList( (x for x in [1]) )
765  self.assertEqual(t,[1])
766 
767  t = TestList(1,2)
768  self.assertEqual(t,[1,2])
769  t = TestList((1,2))
770  self.assertEqual(t,[1,2])
771  t = TestList("one","two")
772  self.assertEqual(t,["one","two"])
773  t = TestList(("one","two"))
774  self.assertEqual(t,["one","two"])
775  t = TestList( [1,2])
776  self.assertEqual(t,[1,2])
777  t = TestList( (x for x in [1,2]) )
778  self.assertEqual(t,[1,2])
779  t = TestList( iter((1,2)) )
780  self.assertEqual(t,[1,2])
781 
782 

◆ testModified()

def Mixins.testMixins.testModified (   self)

Definition at line 846 of file Mixins.py.

846  def testModified(self):
847  class __TestType(_SimpleParameterTypeBase):
848  def _isValid(self,value):
849  return True
850  a = __TestType(1)
851  self.assertEqual(a.isModified(),False)
852  a.setValue(1)
853  self.assertEqual(a.isModified(),False)
854  a.setValue(2)
855  self.assertEqual(a.isModified(),True)
856  a.resetModified()
857  self.assertEqual(a.isModified(),False)

◆ testSpecialImportRegistry()

def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 871 of file Mixins.py.

871  def testSpecialImportRegistry(self):
872  reg = _SpecialImportRegistry()
873  reg.registerSpecialImportForType(int, "import foo")
874  self.assertRaises(lambda x: reg.registerSpecialImportForType(int, "import bar"))
875  reg.registerSpecialImportForType(str, "import bar")
876  self.assertEqual(reg.getSpecialImports(), [])
877  reg.registerUse([1])
878  self.assertEqual(reg.getSpecialImports(), [])
879  reg.registerUse(1)
880  self.assertEqual(reg.getSpecialImports(), ["import foo"])
881  reg.registerUse(1)
882  self.assertEqual(reg.getSpecialImports(), ["import foo"])
883  reg.registerUse("a")
884  self.assertEqual(reg.getSpecialImports(), ["import bar", "import foo"])
885 
886  unittest.main()

◆ testUsingBlock()

def Mixins.testMixins.testUsingBlock (   self)

Definition at line 795 of file Mixins.py.

795  def testUsingBlock(self):
796  a = UsingBlock("a")
797  self.assert_(isinstance(a, _ParameterTypeBase))

Member Data Documentation

◆ TestList

Mixins.testMixins.TestList

Definition at line 792 of file Mixins.py.

◆ tLPTest

Mixins.testMixins.tLPTest

Definition at line 866 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

◆ tLPTestType

Mixins.testMixins.tLPTestType

Definition at line 867 of file Mixins.py.

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
str
#define str(s)
Definition: TestProcessor.cc:52
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:93
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21