CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
Mixins.testMixins Class Reference
Inheritance diagram for Mixins.testMixins:

Public Member Functions

def testClone
 
def testConstruction
 
def testCopy
 
def testLargeList
 
def testLargeParameterizable
 
def testListConstruction
 
def testModified
 
def testSpecialImportRegistry
 
def testUsingBlock
 

Public Attributes

 TestList
 
 tLPTest
 
 tLPTestType
 

Detailed Description

Definition at line 759 of file Mixins.py.

Member Function Documentation

def Mixins.testMixins.testClone (   self)

Definition at line 837 of file Mixins.py.

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

Definition at line 803 of file Mixins.py.

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

Definition at line 822 of file Mixins.py.

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

Definition at line 788 of file Mixins.py.

References submitPVValidationJobs.__init__(), and sistrip::SpyUtilities.range().

789  def testLargeList(self):
790  #lists larger than 255 entries can not be initialized
791  #using the constructor
792  args = [i for i in range(0,300)]
793 
794  t = TestList(*args)
795  pdump= t.dumpPython()
796  class cms(object):
797  def __init__(self):
798  self.TestList = TestList
799  pythonized = eval( pdump, globals(),{'cms':cms()} )
self.assertEqual(t,pythonized)
const uint16_t range(const Frame &aFrame)
Namespace of DDCMS conversion namespace.
def Mixins.testMixins.testLargeParameterizable (   self)

Definition at line 915 of file Mixins.py.

References Mixins.testMixins.tLPTest.

916  def testLargeParameterizable(self):
918  pass
920  def _isValid(self,value):
921  return True
922  class __DummyModule(object):
923  def __init__(self):
924  self.tLPTest = tLPTest
925  self.tLPTestType = tLPTestType
926  p = tLPTest("MyType",** dict( [ ("a"+str(x), tLPTestType(x)) for x in range(0,300) ] ) )
927  #check they are the same
self.assertEqual(p.dumpPython(), eval(p.dumpPython(),{"cms": __DummyModule()}).dumpPython())
const uint16_t range(const Frame &aFrame)
def testLargeParameterizable
Definition: Mixins.py:915
#define str(s)
def Mixins.testMixins.testListConstruction (   self)

Definition at line 760 of file Mixins.py.

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

Definition at line 903 of file Mixins.py.

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

Definition at line 928 of file Mixins.py.

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

Definition at line 800 of file Mixins.py.

801  def testUsingBlock(self):
802  a = UsingBlock("a")
self.assertTrue(isinstance(a, _ParameterTypeBase))
def testUsingBlock
Definition: Mixins.py:800

Member Data Documentation

Mixins.testMixins.TestList

Definition at line 797 of file Mixins.py.

Mixins.testMixins.tLPTest

Definition at line 923 of file Mixins.py.

Referenced by Mixins.testMixins.testLargeParameterizable().

Mixins.testMixins.tLPTestType

Definition at line 924 of file Mixins.py.