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

Member Function Documentation

◆ testClone()

def Mixins.testMixins.testClone (   self)

Definition at line 836 of file Mixins.py.

836  def testClone(self):
837  class __Test(_TypedParameterizable):
838  pass
839  class __TestType(_SimpleParameterTypeBase):
840  def _isValid(self,value):
841  return True
842  class __PSet(_ParameterTypeBase,_Parameterizable):
843  def __init__(self,*arg,**args):
844  #need to call the inits separately
845  _ParameterTypeBase.__init__(self)
846  _Parameterizable.__init__(self,*arg,**args)
847  def dumpPython(self,options=PrintOptions()):
848  return "__PSet(\n"+_Parameterizable.dumpPython(self, options)+options.indentation()+")"
849 
850  a = __Test("MyType",
851  t=__TestType(1),
852  u=__TestType(2),
853  w = __TestType(3),
854  x = __PSet(a = __TestType(4),
855  b = __TestType(6),
856  c = __PSet(gamma = __TestType(5))))
857  b = a.clone(t=3,
858  v=__TestType(4),
859  w= None,
860  x = dict(a = 7,
861  c = dict(gamma = 8),
862  d = __TestType(9)))
863  c = a.clone(x = dict(a=None, c=None))
864  self.assertEqual(a.t.value(),1)
865  self.assertEqual(a.u.value(),2)
866  self.assertEqual(b.t.value(),3)
867  self.assertEqual(b.u.value(),2)
868  self.assertEqual(b.v.value(),4)
869  self.assertEqual(b.x.a.value(),7)
870  self.assertEqual(b.x.b.value(),6)
871  self.assertEqual(b.x.c.gamma.value(),8)
872  self.assertEqual(b.x.d.value(),9)
873  self.assertEqual(hasattr(b,"w"), False)
874  self.assertEqual(hasattr(c.x,"a"), False)
875  self.assertEqual(hasattr(c.x,"c"), False)
876  self.assertRaises(TypeError,a.clone,**{"v":1})
877  d = a.clone(__PSet(k=__TestType(42)))
878  self.assertEqual(d.t.value(), 1)
879  self.assertEqual(d.k.value(), 42)
880  d2 = a.clone(__PSet(t=__TestType(42)))
881  self.assertEqual(d2.t.value(), 42)
882  d3 = a.clone(__PSet(t=__TestType(42)),
883  __PSet(u=__TestType(56)))
884  self.assertEqual(d3.t.value(), 42)
885  self.assertEqual(d3.u.value(), 56)
886  self.assertRaises(ValueError,a.clone,
887  __PSet(t=__TestType(42)),
888  __PSet(t=__TestType(56)))
889  d4 = a.clone(__PSet(t=__TestType(43)), u = 57)
890  self.assertEqual(d4.t.value(), 43)
891  self.assertEqual(d4.u.value(), 57)
892  self.assertRaises(TypeError,a.clone,t=__TestType(43),**{"doesNotExist":57})
893 
894  e = __Test("MyType")
895  self.assertEqual(len(e.parameterNames_()), 0)
896  f = e.clone(__PSet(a = __TestType(1)), b = __TestType(2))
897  self.assertEqual(f.a.value(), 1)
898  self.assertEqual(f.b.value(), 2)
899  g = e.clone()
900  self.assertEqual(len(g.parameterNames_()), 0)
901 
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 802 of file Mixins.py.

802  def testConstruction(self):
803  class __Test(_TypedParameterizable):
804  pass
805  class __TestType(_SimpleParameterTypeBase):
806  def _isValid(self,value):
807  return True
808  class __PSet(_ParameterTypeBase,_Parameterizable):
809  def __init__(self,*arg,**args):
810  #need to call the inits separately
811  _ParameterTypeBase.__init__(self)
812  _Parameterizable.__init__(self,*arg,**args)
813 
814  a = __Test("MyType", __PSet(a=__TestType(1)))
815  self.assertEqual(a.a.value(), 1)
816  b = __Test("MyType", __PSet(a=__TestType(1)), __PSet(b=__TestType(2)))
817  self.assertEqual(b.a.value(), 1)
818  self.assertEqual(b.b.value(), 2)
819  self.assertRaises(ValueError, lambda: __Test("MyType", __PSet(a=__TestType(1)), __PSet(a=__TestType(2))))
820 
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 821 of file Mixins.py.

821  def testCopy(self):
822  class __Test(_TypedParameterizable):
823  pass
824  class __TestType(_SimpleParameterTypeBase):
825  def _isValid(self,value):
826  return True
827  a = __Test("MyType",t=__TestType(1), u=__TestType(2))
828  b = a.copy()
829  self.assertEqual(b.t.value(),1)
830  self.assertEqual(b.u.value(),2)
831 
832  c = __Test("MyType")
833  self.assertEqual(len(c.parameterNames_()), 0)
834  d = c.copy()
835  self.assertEqual(len(d.parameterNames_()), 0)

◆ testLargeList()

def Mixins.testMixins.testLargeList (   self)

Definition at line 787 of file Mixins.py.

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

787  def testLargeList(self):
788  #lists larger than 255 entries can not be initialized
789  #using the constructor
790  args = [i for i in range(0,300)]
791 
792  t = TestList(*args)
793  pdump= t.dumpPython()
794  class cms(object):
795  def __init__(self):
796  self.TestList = TestList
797  pythonized = eval( pdump, globals(),{'cms':cms()} )
798  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 914 of file Mixins.py.

References Mixins.testMixins.tLPTest.

914  def testLargeParameterizable(self):
915  class tLPTest(_TypedParameterizable):
916  pass
917  class tLPTestType(_SimpleParameterTypeBase):
918  def _isValid(self,value):
919  return True
920  class __DummyModule(object):
921  def __init__(self):
922  self.tLPTest = tLPTest
923  self.tLPTestType = tLPTestType
924  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) )
925  #check they are the same
926  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 759 of file Mixins.py.

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

◆ testModified()

def Mixins.testMixins.testModified (   self)

Definition at line 902 of file Mixins.py.

902  def testModified(self):
903  class __TestType(_SimpleParameterTypeBase):
904  def _isValid(self,value):
905  return True
906  a = __TestType(1)
907  self.assertEqual(a.isModified(),False)
908  a.setValue(1)
909  self.assertEqual(a.isModified(),False)
910  a.setValue(2)
911  self.assertEqual(a.isModified(),True)
912  a.resetModified()
913  self.assertEqual(a.isModified(),False)

◆ testSpecialImportRegistry()

def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 927 of file Mixins.py.

927  def testSpecialImportRegistry(self):
928  reg = _SpecialImportRegistry()
929  reg.registerSpecialImportForType(int, "import foo")
930  self.assertRaises(RuntimeError, lambda: reg.registerSpecialImportForType(int, "import bar"))
931  reg.registerSpecialImportForType(str, "import bar")
932  self.assertEqual(reg.getSpecialImports(), [])
933  reg.registerUse([1])
934  self.assertEqual(reg.getSpecialImports(), [])
935  reg.registerUse(1)
936  self.assertEqual(reg.getSpecialImports(), ["import foo"])
937  reg.registerUse(1)
938  self.assertEqual(reg.getSpecialImports(), ["import foo"])
939  reg.registerUse("a")
940  self.assertEqual(reg.getSpecialImports(), ["import bar", "import foo"])
941 
942  unittest.main()

◆ testUsingBlock()

def Mixins.testMixins.testUsingBlock (   self)

Definition at line 799 of file Mixins.py.

799  def testUsingBlock(self):
800  a = UsingBlock("a")
801  self.assertTrue(isinstance(a, _ParameterTypeBase))

Member Data Documentation

◆ TestList

Mixins.testMixins.TestList

Definition at line 796 of file Mixins.py.

◆ tLPTest

Mixins.testMixins.tLPTest

Definition at line 922 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

◆ tLPTestType

Mixins.testMixins.tLPTestType

Definition at line 923 of file Mixins.py.