Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests to work with -OO #50541

Closed
collinwinter mannequin opened this issue Jun 16, 2009 · 6 comments
Closed

Fix tests to work with -OO #50541

collinwinter mannequin opened this issue Jun 16, 2009 · 6 comments
Assignees
Labels
easy tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@collinwinter
Copy link
Mannequin

collinwinter mannequin commented Jun 16, 2009

BPO 6292
Nosy @pitrou, @bitdancer, @briancurtin, @rnk
Files
  • oo_tests.patch: Patch against trunk, r73446
  • issue6292_20091104_v1.patch: Patch against trunk, r76107
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/bitdancer'
    closed_at = <Date 2010-02-24.01:48:32.633>
    created_at = <Date 2009-06-16.17:25:54.056>
    labels = ['easy', 'type-bug', 'tests']
    title = 'Fix tests to work with -OO'
    updated_at = <Date 2010-02-24.02:13:33.862>
    user = 'https://bugs.python.org/collinwinter'

    bugs.python.org fields:

    activity = <Date 2010-02-24.02:13:33.862>
    actor = 'r.david.murray'
    assignee = 'r.david.murray'
    closed = True
    closed_date = <Date 2010-02-24.01:48:32.633>
    closer = 'r.david.murray'
    components = ['Tests']
    creation = <Date 2009-06-16.17:25:54.056>
    creator = 'collinwinter'
    dependencies = []
    files = ['14309', '15258']
    hgrepos = []
    issue_num = 6292
    keywords = ['patch', 'easy']
    message_count = 6.0
    messages = ['89434', '89439', '94897', '99885', '99993', '99995']
    nosy_count = 6.0
    nosy_names = ['collinwinter', 'pitrou', 'jyasskin', 'r.david.murray', 'brian.curtin', 'rnk']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6292'
    versions = ['Python 2.7', 'Python 3.2']

    @collinwinter
    Copy link
    Mannequin Author

    collinwinter mannequin commented Jun 16, 2009

    The attached patch fixes a number of tests to work when -OO is given to
    Python. The majority of these tests are docstring-related, either doctests
    or making assertions about __doc__, with a handful of tests testing that
    assert statements will trigger and another handful of distutils tests that
    are looking for .pyc files.

    With this applied, PYTHONOPTIMIZE=2 ./python.exe -OO Lib/test/regrtest.py
    now passes for trunk.

    @collinwinter collinwinter mannequin added tests Tests in the Lib/test dir easy type-bug An unexpected behavior, bug, or error labels Jun 16, 2009
    @pitrou
    Copy link
    Member

    pitrou commented Jun 16, 2009

    Rather than silently skipping stuff or writing to stderr, the patch
    should, as much as possible, use the new test-skipping API in unittest.
    Perhaps DocTestSuite could centralize some of the effort by inspecting
    sys.flags and skipping accordingly (but users may also set __doc__
    manually).

    @briancurtin
    Copy link
    Member

    I've attached a patch against trunk (r76107) which I think implements
    more of what Antoine is looking for. It builds on Collin's patch but
    uses unittest.skipIf to skip tests which shouldn't be run with -OO. It
    also checks sys.flags.optimize in DocTestSuite and returns a suite with
    a single skipped test as a placeholder in the case that -OO is used.

    One thing that isn't really clean is that test_docxmlrpc has two skipped
    tests and requires work to be done in the tearDown method after those
    methods are skipped. Since setUp gets called even when the test will be
    skipped, the server is started and blocking on getting a request, so I
    just figure out if the test was skipped and do a request for it. Maybe
    that's acceptable, I'm not sure. If anyone has a better way to figure
    get around that, I'm all ears.

    For comparison's sake, regrtest with -OO on r76107 results in 297 OK and
    17 failed, and without optimize it results in 311/2. The patch results
    in 311 OK and 2 failed for runs of regrtest both optimized and not, and
    you can see the improvements more clearly when running the module-level
    tests which were modified.

    @bitdancer
    Copy link
    Member

    Applied a slightly cleaned up (with help from Brian and Matias Torchinsky at the sprint) version of Brian's patch in r78351. Leaving open until merged to py3k.

    @bitdancer bitdancer self-assigned this Feb 23, 2010
    @bitdancer
    Copy link
    Member

    Committed to py3k in r78400. Had to add the make_request_and_skipIf decorator to test_xmplrc as well.

    @bitdancer
    Copy link
    Member

    Benjamin pointed out that the primary copy of lib2to3 is not trunk, so I backed out the change to that package.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants