On 14 April 2010 09:09, Gabriel Genellina <gagsl-...@yahoo.com.ar> wrote: > En Tue, 13 Apr 2010 11:01:19 -0300, John Maclean <jaye...@gmail.com> > escribió: > >> Is there an error in my syntax? Why is my test failing? Line 16. >> >> ====================================================================== >> FAIL: platform.__builtins__.blah >> ---------------------------------------------------------------------- >> Traceback (most recent call last): >> File "stfu/testing/test_pyfactor.py", line 16, in testplatformbuiltins >> self.assertEquals(platform.__builtins__.__class__, "<type 'dict'>") >> AssertionError: <type 'dict'> != "<type 'dict'>" >> >> ---------------------------------------------------------------------- > > To express the condition "SOMEOBJECT must be a dictionary", use: > > isinstance(SOMEOBJECT, dict) > > SOMEOBJECT might actually be an instance of any derived class and still pass > the test; that's usually the desired behavior. > > In the rare cases where only a very specific type is allowed, use this form > instead: > > type(SOMEOBJECT) is dict > > > The test case above should read then: > > self.assert_(isinstance(platform.__builtins__, dict), > type(platform.__builtins__)) > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list >
This is cool. Thanks for your replies. self.assertEqual(platform.__builtins__.__class__, dict, "platform.__class__ supposed to be dict") self.assertEqual(platform.__name__, 'platform' ) -- John Maclean 07739 171 531 MSc (DIC) Enterprise Linux Systems Engineer -- http://mail.python.org/mailman/listinfo/python-list