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

Member Function Documentation

◆ testClone()

def Mixins.testMixins.testClone (   self)

Definition at line 793 of file Mixins.py.

793  def testClone(self):
794  class __Test(_TypedParameterizable):
795  pass
796  class __TestType(_SimpleParameterTypeBase):
797  def _isValid(self,value):
798  return True
799  class __PSet(_ParameterTypeBase,_Parameterizable):
800  def __init__(self,*arg,**args):
801  #need to call the inits separately
802  _ParameterTypeBase.__init__(self)
803  _Parameterizable.__init__(self,*arg,**args)
804  a = __Test("MyType",
805  t=__TestType(1),
806  u=__TestType(2),
807  w = __TestType(3),
808  x = __PSet(a = __TestType(4),
809  b = __TestType(6),
810  c = __PSet(gamma = __TestType(5))))
811  b = a.clone(t=3,
812  v=__TestType(4),
813  w= None,
814  x = dict(a = 7,
815  c = dict(gamma = 8),
816  d = __TestType(9)))
817  c = a.clone(x = dict(a=None, c=None))
818  self.assertEqual(a.t.value(),1)
819  self.assertEqual(a.u.value(),2)
820  self.assertEqual(b.t.value(),3)
821  self.assertEqual(b.u.value(),2)
822  self.assertEqual(b.v.value(),4)
823  self.assertEqual(b.x.a.value(),7)
824  self.assertEqual(b.x.b.value(),6)
825  self.assertEqual(b.x.c.gamma.value(),8)
826  self.assertEqual(b.x.d.value(),9)
827  self.assertEqual(hasattr(b,"w"), False)
828  self.assertEqual(hasattr(c.x,"a"), False)
829  self.assertEqual(hasattr(c.x,"c"), False)
830  self.assertRaises(TypeError,a.clone,None,**{"v":1})

◆ testCopy()

def Mixins.testMixins.testCopy (   self)

Definition at line 783 of file Mixins.py.

783  def testCopy(self):
784  class __Test(_TypedParameterizable):
785  pass
786  class __TestType(_SimpleParameterTypeBase):
787  def _isValid(self,value):
788  return True
789  a = __Test("MyType",t=__TestType(1), u=__TestType(2))
790  b = a.copy()
791  self.assertEqual(b.t.value(),1)
792  self.assertEqual(b.u.value(),2)

◆ testLargeList()

def Mixins.testMixins.testLargeList (   self)

Definition at line 768 of file Mixins.py.

768  def testLargeList(self):
769  #lists larger than 255 entries can not be initialized
770  #using the constructor
771  args = [i for i in range(0,300)]
772 
773  t = TestList(*args)
774  pdump= t.dumpPython()
775  class cms(object):
776  def __init__(self):
777  self.TestList = TestList
778  pythonized = eval( pdump, globals(),{'cms':cms()} )
779  self.assertEqual(t,pythonized)

References resolutioncreator_cfi.object, and FastTimerService_cff.range.

◆ testLargeParameterizable()

def Mixins.testMixins.testLargeParameterizable (   self)

Definition at line 843 of file Mixins.py.

843  def testLargeParameterizable(self):
844  class tLPTest(_TypedParameterizable):
845  pass
846  class tLPTestType(_SimpleParameterTypeBase):
847  def _isValid(self,value):
848  return True
849  class __DummyModule(object):
850  def __init__(self):
851  self.tLPTest = tLPTest
852  self.tLPTestType = tLPTestType
853  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) )
854  #check they are the same
855  self.assertEqual(p.dumpPython(), eval(p.dumpPython(),{"cms": __DummyModule()}).dumpPython())

References Mixins.testMixins.tLPTest.

◆ testListConstruction()

def Mixins.testMixins.testListConstruction (   self)

Definition at line 740 of file Mixins.py.

740  def testListConstruction(self):
741  t = TestList(1)
742  self.assertEqual(t,[1])
743  t = TestList((1,))
744  self.assertEqual(t,[1])
745  t = TestList("one")
746  self.assertEqual(t,["one"])
747  t = TestList( [1,])
748  self.assertEqual(t,[1])
749  t = TestList( (x for x in [1]) )
750  self.assertEqual(t,[1])
751 
752  t = TestList(1,2)
753  self.assertEqual(t,[1,2])
754  t = TestList((1,2))
755  self.assertEqual(t,[1,2])
756  t = TestList("one","two")
757  self.assertEqual(t,["one","two"])
758  t = TestList(("one","two"))
759  self.assertEqual(t,["one","two"])
760  t = TestList( [1,2])
761  self.assertEqual(t,[1,2])
762  t = TestList( (x for x in [1,2]) )
763  self.assertEqual(t,[1,2])
764  t = TestList( iter((1,2)) )
765  self.assertEqual(t,[1,2])
766 
767 

◆ testModified()

def Mixins.testMixins.testModified (   self)

Definition at line 831 of file Mixins.py.

831  def testModified(self):
832  class __TestType(_SimpleParameterTypeBase):
833  def _isValid(self,value):
834  return True
835  a = __TestType(1)
836  self.assertEqual(a.isModified(),False)
837  a.setValue(1)
838  self.assertEqual(a.isModified(),False)
839  a.setValue(2)
840  self.assertEqual(a.isModified(),True)
841  a.resetModified()
842  self.assertEqual(a.isModified(),False)

◆ testSpecialImportRegistry()

def Mixins.testMixins.testSpecialImportRegistry (   self)

Definition at line 856 of file Mixins.py.

856  def testSpecialImportRegistry(self):
857  reg = _SpecialImportRegistry()
858  reg.registerSpecialImportForType(int, "import foo")
859  self.assertRaises(lambda x: reg.registerSpecialImportForType(int, "import bar"))
860  reg.registerSpecialImportForType(str, "import bar")
861  self.assertEqual(reg.getSpecialImports(), [])
862  reg.registerUse([1])
863  self.assertEqual(reg.getSpecialImports(), [])
864  reg.registerUse(1)
865  self.assertEqual(reg.getSpecialImports(), ["import foo"])
866  reg.registerUse(1)
867  self.assertEqual(reg.getSpecialImports(), ["import foo"])
868  reg.registerUse("a")
869  self.assertEqual(reg.getSpecialImports(), ["import bar", "import foo"])
870 
871  unittest.main()

◆ testUsingBlock()

def Mixins.testMixins.testUsingBlock (   self)

Definition at line 780 of file Mixins.py.

780  def testUsingBlock(self):
781  a = UsingBlock("a")
782  self.assert_(isinstance(a, _ParameterTypeBase))

Member Data Documentation

◆ TestList

Mixins.testMixins.TestList

Definition at line 777 of file Mixins.py.

◆ tLPTest

Mixins.testMixins.tLPTest

Definition at line 851 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

◆ tLPTestType

Mixins.testMixins.tLPTestType

Definition at line 852 of file Mixins.py.

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
str
#define str(s)
Definition: TestProcessor.cc:48
ConfigBuilder.dumpPython
def dumpPython(process, name)
Definition: ConfigBuilder.py:92
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21