def testTypeAdapter(self): f = TestFixture() a = adapterOnField(f, 'sampleInt') a.set(a.parse("123456")) self.assertEquals(123456, f.sampleInt) self.assertEquals("-234567", str(a.parse("-234567"))) a = adapterOnMethod(f, "pi") # we do not currently support creating an adapter from a method declaration # a = adapterOnMethod(f, f.__class__.pi) self.assert_(abs(3.14159 - a.invoke()) < 0.00001) self.assertEquals(3.14159862, a.invoke()) a = adapterOnField(f, 'sampleString') a.set(a.parse("xyzzy")) self.assertEquals('xyzzy', f.sampleString) a = adapterOnField(f, 'sampleFloat') a.set(a.parse("6.02e23")) # not sure what the 1e17 is supposed to be here. If it's the epsilon, # the Python version of xUnit does not support it. We can get a # similar effect by inserting a .precision into _typeDict. self.assertEquals(6.02e23, f.sampleFloat) #, 1e17
def testTypeAdapter(self): f = TestFixture() a = adapterOnField(f, "sampleInt") a.set(a.parse("123456")) self.assertEquals(123456, f.sampleInt) self.assertEquals("-234567", str(a.parse("-234567"))) a = adapterOnMethod(f, "pi") # we do not currently support creating an adapter from a method declaration # a = adapterOnMethod(f, f.__class__.pi) self.assert_(abs(3.14159 - a.invoke()) < 0.00001) self.assertEquals(3.14159862, a.invoke()) a = adapterOnField(f, "sampleString") a.set(a.parse("xyzzy")) self.assertEquals("xyzzy", f.sampleString) a = adapterOnField(f, "sampleFloat") a.set(a.parse("6.02e23")) # not sure what the 1e17 is supposed to be here. If it's the epsilon, # the Python version of xUnit does not support it. We can get a # similar effect by inserting a .precision into _typeDict. self.assertEquals(6.02e23, f.sampleFloat) # , 1e17
def bindMethod(self, name): classObj = self.getTargetClass() return adapterOnMethod(self, name, targetClass=classObj)
def check_(self): text = self.camel(self.cells.more.text()) adapter = adapterOnMethod(self.actor, text) Fixture.check(self, self.cells.more.more, adapter)
def enter_(self): methodName = self.camel(self.cells.more.text()) adapter = adapterOnMethod(self.actor, methodName) parameterString = self.cells.more.more.text() args = adapter.parse(parameterString) adapter.method(self.actor, args)
def bindMethod(self, name): classObj = self.getTargetClass() return adapterOnMethod(self, name, targetClass=classObj)