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

Member Function Documentation

◆ testClone()

def Mixins.testMixins.testClone (   self)

Definition at line 847 of file Mixins.py.

847  def testClone(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  def dumpPython(self,options=PrintOptions()):
859  return "__PSet(\n"+_Parameterizable.dumpPython(self, options)+options.indentation()+")"
860 
861  a = __Test("MyType",
862  t=__TestType(1),
863  u=__TestType(2),
864  w = __TestType(3),
865  x = __PSet(a = __TestType(4),
866  b = __TestType(6),
867  c = __PSet(gamma = __TestType(5))))
868  b = a.clone(t=3,
869  v=__TestType(4),
870  w= None,
871  x = dict(a = 7,
872  c = dict(gamma = 8),
873  d = __TestType(9)))
874  c = a.clone(x = dict(a=None, c=None))
875  self.assertEqual(a.t.value(),1)
876  self.assertEqual(a.u.value(),2)
877  self.assertEqual(b.t.value(),3)
878  self.assertEqual(b.u.value(),2)
879  self.assertEqual(b.v.value(),4)
880  self.assertEqual(b.x.a.value(),7)
881  self.assertEqual(b.x.b.value(),6)
882  self.assertEqual(b.x.c.gamma.value(),8)
883  self.assertEqual(b.x.d.value(),9)
884  self.assertEqual(hasattr(b,"w"), False)
885  self.assertEqual(hasattr(c.x,"a"), False)
886  self.assertEqual(hasattr(c.x,"c"), False)
887  self.assertRaises(TypeError,a.clone,**{"v":1})
888  d = a.clone(__PSet(k=__TestType(42)))
889  self.assertEqual(d.t.value(), 1)
890  self.assertEqual(d.k.value(), 42)
891  d2 = a.clone(__PSet(t=__TestType(42)))
892  self.assertEqual(d2.t.value(), 42)
893  d3 = a.clone(__PSet(t=__TestType(42)),
894  __PSet(u=__TestType(56)))
895  self.assertEqual(d3.t.value(), 42)
896  self.assertEqual(d3.u.value(), 56)
897  self.assertRaises(ValueError,a.clone,
898  __PSet(t=__TestType(42)),
899  __PSet(t=__TestType(56)))
900  d4 = a.clone(__PSet(t=__TestType(43)), u = 57)
901  self.assertEqual(d4.t.value(), 43)
902  self.assertEqual(d4.u.value(), 57)
903  self.assertRaises(TypeError,a.clone,t=__TestType(43),**{"doesNotExist":57})
904 
905  e = __Test("MyType")
906  self.assertEqual(len(e.parameterNames_()), 0)
907  f = e.clone(__PSet(a = __TestType(1)), b = __TestType(2))
908  self.assertEqual(f.a.value(), 1)
909  self.assertEqual(f.b.value(), 2)
910  g = e.clone()
911  self.assertEqual(len(g.parameterNames_()), 0)
912 
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 813 of file Mixins.py.

813  def testConstruction(self):
814  class __Test(_TypedParameterizable):
815  pass
816  class __TestType(_SimpleParameterTypeBase):
817  def _isValid(self,value):
818  return True
819  class __PSet(_ParameterTypeBase,_Parameterizable):
820  def __init__(self,*arg,**args):
821  #need to call the inits separately
822  _ParameterTypeBase.__init__(self)
823  _Parameterizable.__init__(self,*arg,**args)
824 
825  a = __Test("MyType", __PSet(a=__TestType(1)))
826  self.assertEqual(a.a.value(), 1)
827  b = __Test("MyType", __PSet(a=__TestType(1)), __PSet(b=__TestType(2)))
828  self.assertEqual(b.a.value(), 1)
829  self.assertEqual(b.b.value(), 2)
830  self.assertRaises(ValueError, lambda: __Test("MyType", __PSet(a=__TestType(1)), __PSet(a=__TestType(2))))
831 
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 832 of file Mixins.py.

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

◆ testInvalidTypeChange()

def Mixins.testMixins.testInvalidTypeChange (   self)

Definition at line 952 of file Mixins.py.

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

◆ testLargeList()

def Mixins.testMixins.testLargeList (   self)

Definition at line 798 of file Mixins.py.

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

798  def testLargeList(self):
799  #lists larger than 255 entries can not be initialized
800  #using the constructor
801  args = [i for i in range(0,300)]
802 
803  t = TestList(*args)
804  pdump= t.dumpPython()
805  class cms(object):
806  def __init__(self):
807  self.TestList = TestList
808  pythonized = eval( pdump, globals(),{'cms':cms()} )
809  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 925 of file Mixins.py.

References Mixins.testMixins.tLPTest.

925  def testLargeParameterizable(self):
926  class tLPTest(_TypedParameterizable):
927  pass
928  class tLPTestType(_SimpleParameterTypeBase):
929  def _isValid(self,value):
930  return True
931  class __DummyModule(object):
932  def __init__(self):
933  self.tLPTest = tLPTest
934  self.tLPTestType = tLPTestType
935  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) )
936  #check they are the same
937  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 770 of file Mixins.py.

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

◆ testModified()

def Mixins.testMixins.testModified (   self)

Definition at line 913 of file Mixins.py.

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

◆ testSpecialImportRegistry()

def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 938 of file Mixins.py.

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

◆ testUsingBlock()

def Mixins.testMixins.testUsingBlock (   self)

Definition at line 810 of file Mixins.py.

810  def testUsingBlock(self):
811  a = UsingBlock("a")
812  self.assertTrue(isinstance(a, _ParameterTypeBase))

Member Data Documentation

◆ TestList

Mixins.testMixins.TestList

Definition at line 807 of file Mixins.py.

◆ tLPTest

Mixins.testMixins.tLPTest

Definition at line 933 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

◆ tLPTestType

Mixins.testMixins.tLPTestType

Definition at line 934 of file Mixins.py.