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

Reply via email to