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

Public Attributes

 TestList
 
 tLPTest
 
 tLPTestType
 

Detailed Description

Definition at line 781 of file Mixins.py.

Member Function Documentation

◆ testClone()

def Mixins.testMixins.testClone (   self)

Definition at line 883 of file Mixins.py.

883  def testClone(self):
884  class __Test(_TypedParameterizable):
885  pass
886  class __TestType(_SimpleParameterTypeBase):
887  def _isValid(self,value):
888  return True
889  class __PSet(_ParameterTypeBase,_Parameterizable):
890  def __init__(self,*arg,**args):
891  #need to call the inits separately
892  _ParameterTypeBase.__init__(self)
893  _Parameterizable.__init__(self,*arg,**args)
894  def dumpPython(self,options=PrintOptions()):
895  return "__PSet(\n"+_Parameterizable.dumpPython(self, options)+options.indentation()+")"
896 
897  a = __Test("MyType",
898  t=__TestType(1),
899  u=__TestType(2),
900  w = __TestType(3),
901  x = __PSet(a = __TestType(4),
902  b = __TestType(6),
903  c = __PSet(gamma = __TestType(5))))
904  b = a.clone(t=3,
905  v=__TestType(4),
906  w= None,
907  x = dict(a = 7,
908  c = dict(gamma = 8),
909  d = __TestType(9)))
910  c = a.clone(x = dict(a=None, c=None))
911  self.assertEqual(a.t.value(),1)
912  self.assertEqual(a.u.value(),2)
913  self.assertEqual(b.t.value(),3)
914  self.assertEqual(b.u.value(),2)
915  self.assertEqual(b.v.value(),4)
916  self.assertEqual(b.x.a.value(),7)
917  self.assertEqual(b.x.b.value(),6)
918  self.assertEqual(b.x.c.gamma.value(),8)
919  self.assertEqual(b.x.d.value(),9)
920  self.assertEqual(hasattr(b,"w"), False)
921  self.assertEqual(hasattr(c.x,"a"), False)
922  self.assertEqual(hasattr(c.x,"c"), False)
923  self.assertRaises(TypeError,a.clone,**{"v":1})
924  d = a.clone(__PSet(k=__TestType(42)))
925  self.assertEqual(d.t.value(), 1)
926  self.assertEqual(d.k.value(), 42)
927  d2 = a.clone(__PSet(t=__TestType(42)))
928  self.assertEqual(d2.t.value(), 42)
929  d3 = a.clone(__PSet(t=__TestType(42)),
930  __PSet(u=__TestType(56)))
931  self.assertEqual(d3.t.value(), 42)
932  self.assertEqual(d3.u.value(), 56)
933  self.assertRaises(ValueError,a.clone,
934  __PSet(t=__TestType(42)),
935  __PSet(t=__TestType(56)))
936  d4 = a.clone(__PSet(t=__TestType(43)), u = 57)
937  self.assertEqual(d4.t.value(), 43)
938  self.assertEqual(d4.u.value(), 57)
939  self.assertRaises(TypeError,a.clone,t=__TestType(43),**{"doesNotExist":57})
940 
941  e = __Test("MyType")
942  self.assertEqual(len(e.parameterNames_()), 0)
943  f = e.clone(__PSet(a = __TestType(1)), b = __TestType(2))
944  self.assertEqual(f.a.value(), 1)
945  self.assertEqual(f.b.value(), 2)
946  g = e.clone()
947  self.assertEqual(len(g.parameterNames_()), 0)
948 
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 825 of file Mixins.py.

825  def testConstruction(self):
826  class __Test(_TypedParameterizable):
827  pass
828  class __TestType(_SimpleParameterTypeBase):
829  def _isValid(self,value):
830  return True
831  class __PSet(_ParameterTypeBase,_Parameterizable):
832  def __init__(self,*arg,**args):
833  #need to call the inits separately
834  _ParameterTypeBase.__init__(self)
835  _Parameterizable.__init__(self,*arg,**args)
836 
837  a = __Test("MyType", __PSet(a=__TestType(1)))
838  self.assertEqual(a.a.value(), 1)
839  b = __Test("MyType", __PSet(a=__TestType(1)), __PSet(b=__TestType(2)))
840  self.assertEqual(b.a.value(), 1)
841  self.assertEqual(b.b.value(), 2)
842  self.assertRaises(ValueError, lambda: __Test("MyType", __PSet(a=__TestType(1)), __PSet(a=__TestType(2))))
843  c = __Test("MyType", dict(a=__TestType(1)), dict(b=__TestType(2)))
844  self.assertEqual(c.a.value(), 1)
845  self.assertEqual(c.b.value(), 2)
846  self.assertRaises(ValueError, lambda: __Test("MyType", dict(a=__TestType(1)), dict(a=__TestType(2))))
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 868 of file Mixins.py.

868  def testCopy(self):
869  class __Test(_TypedParameterizable):
870  pass
871  class __TestType(_SimpleParameterTypeBase):
872  def _isValid(self,value):
873  return True
874  a = __Test("MyType",t=__TestType(1), u=__TestType(2))
875  b = a.copy()
876  self.assertEqual(b.t.value(),1)
877  self.assertEqual(b.u.value(),2)
878 
879  c = __Test("MyType")
880  self.assertEqual(len(c.parameterNames_()), 0)
881  d = c.copy()
882  self.assertEqual(len(d.parameterNames_()), 0)

◆ testInvalidTypeChange()

def Mixins.testMixins.testInvalidTypeChange (   self)

Definition at line 988 of file Mixins.py.

988  def testInvalidTypeChange(self):
989  class __Test(_TypedParameterizable):
990  pass
991  class __TestTypeA(_SimpleParameterTypeBase):
992  def _isValid(self,value):
993  return True
994  class __TestTypeB(_SimpleParameterTypeBase):
995  def _isValid(self,value):
996  return True
997  pass
998  a = __Test("MyType",
999  t=__TestTypeA(1))
1000  self.assertRaises(TypeError, lambda : setattr(a,'t',__TestTypeB(2)))
1001 
1002 
1003  unittest.main()

◆ testLargeList()

def Mixins.testMixins.testLargeList (   self)

Definition at line 810 of file Mixins.py.

References submitPVValidationJobs.__init__(), default_text_conditions_cfi.object, and isotrackApplyRegressor.range.

810  def testLargeList(self):
811  #lists larger than 255 entries can not be initialized
812  #using the constructor
813  args = [i for i in range(0,300)]
814 
815  t = TestList(*args)
816  pdump= t.dumpPython()
817  class cms(object):
818  def __init__(self):
819  self.TestList = TestList
820  pythonized = eval( pdump, globals(),{'cms':cms()} )
821  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 961 of file Mixins.py.

References Mixins.testMixins.tLPTest.

961  def testLargeParameterizable(self):
962  class tLPTest(_TypedParameterizable):
963  pass
964  class tLPTestType(_SimpleParameterTypeBase):
965  def _isValid(self,value):
966  return True
967  class __DummyModule(object):
968  def __init__(self):
969  self.tLPTest = tLPTest
970  self.tLPTestType = tLPTestType
971  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) )
972  #check they are the same
973  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 782 of file Mixins.py.

782  def testListConstruction(self):
783  t = TestList(1)
784  self.assertEqual(t,[1])
785  t = TestList((1,))
786  self.assertEqual(t,[1])
787  t = TestList("one")
788  self.assertEqual(t,["one"])
789  t = TestList( [1,])
790  self.assertEqual(t,[1])
791  t = TestList( (x for x in [1]) )
792  self.assertEqual(t,[1])
793 
794  t = TestList(1,2)
795  self.assertEqual(t,[1,2])
796  t = TestList((1,2))
797  self.assertEqual(t,[1,2])
798  t = TestList("one","two")
799  self.assertEqual(t,["one","two"])
800  t = TestList(("one","two"))
801  self.assertEqual(t,["one","two"])
802  t = TestList( [1,2])
803  self.assertEqual(t,[1,2])
804  t = TestList( (x for x in [1,2]) )
805  self.assertEqual(t,[1,2])
806  t = TestList( iter((1,2)) )
807  self.assertEqual(t,[1,2])
808 
809 

◆ testModified()

def Mixins.testMixins.testModified (   self)

Definition at line 949 of file Mixins.py.

949  def testModified(self):
950  class __TestType(_SimpleParameterTypeBase):
951  def _isValid(self,value):
952  return True
953  a = __TestType(1)
954  self.assertEqual(a.isModified(),False)
955  a.setValue(1)
956  self.assertEqual(a.isModified(),False)
957  a.setValue(2)
958  self.assertEqual(a.isModified(),True)
959  a.resetModified()
960  self.assertEqual(a.isModified(),False)

◆ testSpecialImportRegistry()

def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 974 of file Mixins.py.

974  def testSpecialImportRegistry(self):
975  reg = _SpecialImportRegistry()
976  reg.registerSpecialImportForType(int, "import foo")
977  self.assertRaises(RuntimeError, lambda: reg.registerSpecialImportForType(int, "import bar"))
978  reg.registerSpecialImportForType(str, "import bar")
979  self.assertEqual(reg.getSpecialImports(), [])
980  reg.registerUse([1])
981  self.assertEqual(reg.getSpecialImports(), [])
982  reg.registerUse(1)
983  self.assertEqual(reg.getSpecialImports(), ["import foo"])
984  reg.registerUse(1)
985  self.assertEqual(reg.getSpecialImports(), ["import foo"])
986  reg.registerUse("a")
987  self.assertEqual(reg.getSpecialImports(), ["import bar", "import foo"])

◆ testUpdate_()

def Mixins.testMixins.testUpdate_ (   self)

Definition at line 847 of file Mixins.py.

847  def testUpdate_(self):
848  class __Test(_TypedParameterizable):
849  pass
850  class __TestType(_SimpleParameterTypeBase):
851  def _isValid(self,value):
852  return True
853  class __PSet(_ParameterTypeBase,_Parameterizable):
854  def __init__(self,*arg,**args):
855  #need to call the inits separately
856  _ParameterTypeBase.__init__(self)
857  _Parameterizable.__init__(self,*arg,**args)
858  a = __Test("MyType", a = __TestType(1))
859  a.update_(dict(b=__TestType(2)))
860  self.assertEqual(a.a.value(), 1)
861  self.assertEqual(a.b.value(), 2)
862  a.update_(dict(a=3))
863  self.assertEqual(a.a.value(), 3)
864  a.update_(__PSet(a=__TestType(5)))
865  self.assertEqual(a.a.value(), 5)
866  self.assertRaises(TypeError, lambda: a.update_(dict(c=6)))
867 
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)

◆ testUsingBlock()

def Mixins.testMixins.testUsingBlock (   self)

Definition at line 822 of file Mixins.py.

822  def testUsingBlock(self):
823  a = UsingBlock("a")
824  self.assertTrue(isinstance(a, _ParameterTypeBase))

Member Data Documentation

◆ TestList

Mixins.testMixins.TestList

Definition at line 819 of file Mixins.py.

◆ tLPTest

Mixins.testMixins.tLPTest

Definition at line 969 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

◆ tLPTestType

Mixins.testMixins.tLPTestType

Definition at line 970 of file Mixins.py.