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 testConstruction (self)
 
def testCopy (self)
 
def testInvalidTypeChange (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 765 of file Mixins.py.

Member Function Documentation

◆ testClone()

def Mixins.testMixins.testClone (   self)

Definition at line 843 of file Mixins.py.

843  def testClone(self):
844  class __Test(_TypedParameterizable):
845  pass
846  class __TestType(_SimpleParameterTypeBase):
847  def _isValid(self,value):
848  return True
849  class __PSet(_ParameterTypeBase,_Parameterizable):
850  def __init__(self,*arg,**args):
851  #need to call the inits separately
852  _ParameterTypeBase.__init__(self)
853  _Parameterizable.__init__(self,*arg,**args)
854  def dumpPython(self,options=PrintOptions()):
855  return "__PSet(\n"+_Parameterizable.dumpPython(self, options)+options.indentation()+")"
856 
857  a = __Test("MyType",
858  t=__TestType(1),
859  u=__TestType(2),
860  w = __TestType(3),
861  x = __PSet(a = __TestType(4),
862  b = __TestType(6),
863  c = __PSet(gamma = __TestType(5))))
864  b = a.clone(t=3,
865  v=__TestType(4),
866  w= None,
867  x = dict(a = 7,
868  c = dict(gamma = 8),
869  d = __TestType(9)))
870  c = a.clone(x = dict(a=None, c=None))
871  self.assertEqual(a.t.value(),1)
872  self.assertEqual(a.u.value(),2)
873  self.assertEqual(b.t.value(),3)
874  self.assertEqual(b.u.value(),2)
875  self.assertEqual(b.v.value(),4)
876  self.assertEqual(b.x.a.value(),7)
877  self.assertEqual(b.x.b.value(),6)
878  self.assertEqual(b.x.c.gamma.value(),8)
879  self.assertEqual(b.x.d.value(),9)
880  self.assertEqual(hasattr(b,"w"), False)
881  self.assertEqual(hasattr(c.x,"a"), False)
882  self.assertEqual(hasattr(c.x,"c"), False)
883  self.assertRaises(TypeError,a.clone,**{"v":1})
884  d = a.clone(__PSet(k=__TestType(42)))
885  self.assertEqual(d.t.value(), 1)
886  self.assertEqual(d.k.value(), 42)
887  d2 = a.clone(__PSet(t=__TestType(42)))
888  self.assertEqual(d2.t.value(), 42)
889  d3 = a.clone(__PSet(t=__TestType(42)),
890  __PSet(u=__TestType(56)))
891  self.assertEqual(d3.t.value(), 42)
892  self.assertEqual(d3.u.value(), 56)
893  self.assertRaises(ValueError,a.clone,
894  __PSet(t=__TestType(42)),
895  __PSet(t=__TestType(56)))
896  d4 = a.clone(__PSet(t=__TestType(43)), u = 57)
897  self.assertEqual(d4.t.value(), 43)
898  self.assertEqual(d4.u.value(), 57)
899  self.assertRaises(TypeError,a.clone,t=__TestType(43),**{"doesNotExist":57})
900 
901  e = __Test("MyType")
902  self.assertEqual(len(e.parameterNames_()), 0)
903  f = e.clone(__PSet(a = __TestType(1)), b = __TestType(2))
904  self.assertEqual(f.a.value(), 1)
905  self.assertEqual(f.b.value(), 2)
906  g = e.clone()
907  self.assertEqual(len(g.parameterNames_()), 0)
908 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def dumpPython(process, name)

◆ testConstruction()

def Mixins.testMixins.testConstruction (   self)

Definition at line 809 of file Mixins.py.

809  def testConstruction(self):
810  class __Test(_TypedParameterizable):
811  pass
812  class __TestType(_SimpleParameterTypeBase):
813  def _isValid(self,value):
814  return True
815  class __PSet(_ParameterTypeBase,_Parameterizable):
816  def __init__(self,*arg,**args):
817  #need to call the inits separately
818  _ParameterTypeBase.__init__(self)
819  _Parameterizable.__init__(self,*arg,**args)
820 
821  a = __Test("MyType", __PSet(a=__TestType(1)))
822  self.assertEqual(a.a.value(), 1)
823  b = __Test("MyType", __PSet(a=__TestType(1)), __PSet(b=__TestType(2)))
824  self.assertEqual(b.a.value(), 1)
825  self.assertEqual(b.b.value(), 2)
826  self.assertRaises(ValueError, lambda: __Test("MyType", __PSet(a=__TestType(1)), __PSet(a=__TestType(2))))
827 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

◆ testCopy()

def Mixins.testMixins.testCopy (   self)

Definition at line 828 of file Mixins.py.

828  def testCopy(self):
829  class __Test(_TypedParameterizable):
830  pass
831  class __TestType(_SimpleParameterTypeBase):
832  def _isValid(self,value):
833  return True
834  a = __Test("MyType",t=__TestType(1), u=__TestType(2))
835  b = a.copy()
836  self.assertEqual(b.t.value(),1)
837  self.assertEqual(b.u.value(),2)
838 
839  c = __Test("MyType")
840  self.assertEqual(len(c.parameterNames_()), 0)
841  d = c.copy()
842  self.assertEqual(len(d.parameterNames_()), 0)

◆ testInvalidTypeChange()

def Mixins.testMixins.testInvalidTypeChange (   self)

Definition at line 948 of file Mixins.py.

948  def testInvalidTypeChange(self):
949  class __Test(_TypedParameterizable):
950  pass
951  class __TestTypeA(_SimpleParameterTypeBase):
952  def _isValid(self,value):
953  return True
954  class __TestTypeB(_SimpleParameterTypeBase):
955  def _isValid(self,value):
956  return True
957  pass
958  a = __Test("MyType",
959  t=__TestTypeA(1))
960  self.assertRaises(TypeError, lambda : setattr(a,'t',__TestTypeB(2)))
961 
962 
963  unittest.main()

◆ testLargeList()

def Mixins.testMixins.testLargeList (   self)

Definition at line 794 of file Mixins.py.

References submitPVValidationJobs.__init__(), resolutioncreator_cfi.object, and FastTimerService_cff.range.

794  def testLargeList(self):
795  #lists larger than 255 entries can not be initialized
796  #using the constructor
797  args = [i for i in range(0,300)]
798 
799  t = TestList(*args)
800  pdump= t.dumpPython()
801  class cms(object):
802  def __init__(self):
803  self.TestList = TestList
804  pythonized = eval( pdump, globals(),{'cms':cms()} )
805  self.assertEqual(t,pythonized)
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
Namespace of DDCMS conversion namespace.

◆ testLargeParameterizable()

def Mixins.testMixins.testLargeParameterizable (   self)

Definition at line 921 of file Mixins.py.

References Mixins.testMixins.tLPTest.

921  def testLargeParameterizable(self):
922  class tLPTest(_TypedParameterizable):
923  pass
924  class tLPTestType(_SimpleParameterTypeBase):
925  def _isValid(self,value):
926  return True
927  class __DummyModule(object):
928  def __init__(self):
929  self.tLPTest = tLPTest
930  self.tLPTestType = tLPTestType
931  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) )
932  #check they are the same
933  self.assertEqual(p.dumpPython(), eval(p.dumpPython(),{"cms": __DummyModule()}).dumpPython())
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def dumpPython(process, name)
#define str(s)

◆ testListConstruction()

def Mixins.testMixins.testListConstruction (   self)

Definition at line 766 of file Mixins.py.

766  def testListConstruction(self):
767  t = TestList(1)
768  self.assertEqual(t,[1])
769  t = TestList((1,))
770  self.assertEqual(t,[1])
771  t = TestList("one")
772  self.assertEqual(t,["one"])
773  t = TestList( [1,])
774  self.assertEqual(t,[1])
775  t = TestList( (x for x in [1]) )
776  self.assertEqual(t,[1])
777 
778  t = TestList(1,2)
779  self.assertEqual(t,[1,2])
780  t = TestList((1,2))
781  self.assertEqual(t,[1,2])
782  t = TestList("one","two")
783  self.assertEqual(t,["one","two"])
784  t = TestList(("one","two"))
785  self.assertEqual(t,["one","two"])
786  t = TestList( [1,2])
787  self.assertEqual(t,[1,2])
788  t = TestList( (x for x in [1,2]) )
789  self.assertEqual(t,[1,2])
790  t = TestList( iter((1,2)) )
791  self.assertEqual(t,[1,2])
792 
793 

◆ testModified()

def Mixins.testMixins.testModified (   self)

Definition at line 909 of file Mixins.py.

909  def testModified(self):
910  class __TestType(_SimpleParameterTypeBase):
911  def _isValid(self,value):
912  return True
913  a = __TestType(1)
914  self.assertEqual(a.isModified(),False)
915  a.setValue(1)
916  self.assertEqual(a.isModified(),False)
917  a.setValue(2)
918  self.assertEqual(a.isModified(),True)
919  a.resetModified()
920  self.assertEqual(a.isModified(),False)

◆ testSpecialImportRegistry()

def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 934 of file Mixins.py.

934  def testSpecialImportRegistry(self):
935  reg = _SpecialImportRegistry()
936  reg.registerSpecialImportForType(int, "import foo")
937  self.assertRaises(RuntimeError, lambda: reg.registerSpecialImportForType(int, "import bar"))
938  reg.registerSpecialImportForType(str, "import bar")
939  self.assertEqual(reg.getSpecialImports(), [])
940  reg.registerUse([1])
941  self.assertEqual(reg.getSpecialImports(), [])
942  reg.registerUse(1)
943  self.assertEqual(reg.getSpecialImports(), ["import foo"])
944  reg.registerUse(1)
945  self.assertEqual(reg.getSpecialImports(), ["import foo"])
946  reg.registerUse("a")
947  self.assertEqual(reg.getSpecialImports(), ["import bar", "import foo"])

◆ testUsingBlock()

def Mixins.testMixins.testUsingBlock (   self)

Definition at line 806 of file Mixins.py.

806  def testUsingBlock(self):
807  a = UsingBlock("a")
808  self.assertTrue(isinstance(a, _ParameterTypeBase))

Member Data Documentation

◆ TestList

Mixins.testMixins.TestList

Definition at line 803 of file Mixins.py.

◆ tLPTest

Mixins.testMixins.tLPTest

Definition at line 929 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

◆ tLPTestType

Mixins.testMixins.tLPTestType

Definition at line 930 of file Mixins.py.