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

Member Function Documentation

◆ testClone()

def Mixins.testMixins.testClone (   self)

Definition at line 806 of file Mixins.py.

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

◆ testCopy()

def Mixins.testMixins.testCopy (   self)

Definition at line 796 of file Mixins.py.

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

◆ testLargeList()

def Mixins.testMixins.testLargeList (   self)

Definition at line 781 of file Mixins.py.

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

References resolutioncreator_cfi.object, and FastTimerService_cff.range.

◆ testLargeParameterizable()

def Mixins.testMixins.testLargeParameterizable (   self)

Definition at line 856 of file Mixins.py.

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

References Mixins.testMixins.tLPTest.

◆ testListConstruction()

def Mixins.testMixins.testListConstruction (   self)

Definition at line 753 of file Mixins.py.

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

◆ testModified()

def Mixins.testMixins.testModified (   self)

Definition at line 844 of file Mixins.py.

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

◆ testSpecialImportRegistry()

def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 869 of file Mixins.py.

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

◆ testUsingBlock()

def Mixins.testMixins.testUsingBlock (   self)

Definition at line 793 of file Mixins.py.

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

Member Data Documentation

◆ TestList

Mixins.testMixins.TestList

Definition at line 790 of file Mixins.py.

◆ tLPTest

Mixins.testMixins.tLPTest

Definition at line 864 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

◆ tLPTestType

Mixins.testMixins.tLPTestType

Definition at line 865 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:51
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:92
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21