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

Member Function Documentation

◆ testClone()

def Mixins.testMixins.testClone (   self)

Definition at line 846 of file Mixins.py.

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

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

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

◆ testInvalidTypeChange()

def Mixins.testMixins.testInvalidTypeChange (   self)

Definition at line 951 of file Mixins.py.

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

◆ testLargeList()

def Mixins.testMixins.testLargeList (   self)

Definition at line 797 of file Mixins.py.

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

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

References Mixins.testMixins.tLPTest.

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

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

◆ testModified()

def Mixins.testMixins.testModified (   self)

Definition at line 912 of file Mixins.py.

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

◆ testSpecialImportRegistry()

def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 937 of file Mixins.py.

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

◆ testUsingBlock()

def Mixins.testMixins.testUsingBlock (   self)

Definition at line 809 of file Mixins.py.

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

Member Data Documentation

◆ TestList

Mixins.testMixins.TestList

Definition at line 806 of file Mixins.py.

◆ tLPTest

Mixins.testMixins.tLPTest

Definition at line 932 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

◆ tLPTestType

Mixins.testMixins.tLPTestType

Definition at line 933 of file Mixins.py.