A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-September/017599.html below:

[Python-Dev] A baffler in test_repr

[Python-Dev] A baffler in test_reprTim Peters tim.one@home.com
Sat, 22 Sep 2001 23:29:49 -0400
test_repr (very) recently started failing for me, on Windows, but only when
doing a full run of the test suite.  Same symptom in release or debug
builds.  test_repr does not fail when run alone, and regardless of whether
run directly from cmdline, or via "regrtest test_repr".

Here's the failure:

test_repr
test test_repr failed -- Traceback (most recent call last):
  File "../lib/test\test_repr.py", line 156, in test_descriptors
    self.failUnless(repr(x).startswith('<staticmethod object at 0x'))
  File "C:\CODE\PYTHON\lib\unittest.py", line 256, in failUnless
    if not expr: raise self.failureException, msg
AssertionError

This is the code that's failing:

        class C:
            def foo(cls): pass
        x = staticmethod(C.foo)
        self.failUnless(repr(x).startswith('<staticmethod object at 0x'))

By putting

        import sys; print >> sys.stderr, '*' * 30, repr(x)

before the last line, when it fails repr(x) is actually:

    <staticmethod instance at 0x017E26C0>

when it fails (although the address varies, of course).  How can it be
either "an object" or "an instance" depending on how the test is run?  A
staticmethod doesn't contain enough data that it's possible to forget to
initialize any of it <0.7 wink>.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4