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

gh-92886: Fixing test that fails when running with optimizations (-O) in test_imaplib.py #93237

Merged
merged 2 commits into from Jun 4, 2022

Conversation

jackh-ncl
Copy link
Contributor

@jackh-ncl jackh-ncl commented May 25, 2022

#92886

Before:

$ ./python.exe -Om unittest test.test_imaplib
...
======================================================================
ERROR: test_dump_ur (test.test_imaplib.ThreadedNetworkedTests.test_dump_ur)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/.../dev/cpython/Lib/test/support/threading_helper.py", line 63, in decorator
    return func(*args)
           ^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/test/test_imaplib.py", line 948, in test_dump_ur
    with mock.patch.object(imap, '_mesg') as mock_mesg:
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/unittest/mock.py", line 1427, in __enter__
    original, local = self.get_original()
                      ^^^^^^^^^^^^^^^^^^^
  File "/Users/.../dev/cpython/Lib/unittest/mock.py", line 1400, in get_original
    raise AttributeError(
    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: <imaplib.IMAP4 object at 0x1032a3bc0> does not have the attribute '_mesg'

----------------------------------------------------------------------
Ran 103 tests in 6.203s

FAILED (errors=1, skipped=55)

After:

./python.exe -Om unittest test.test_zipimport
...
----------------------------------------------------------------------
Ran 103 tests in 6.156s

OK (skipped=56)

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 25, 2022

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@bedevere-bot bedevere-bot added tests awaiting review labels May 25, 2022
@jackh-ncl jackh-ncl marked this pull request as ready for review May 25, 2022
@jackh-ncl jackh-ncl requested a review from as a code owner May 25, 2022
@@ -939,6 +939,7 @@ def test_with_statement_logout(self):

@threading_helper.reap_threads
@cpython_only
@unittest.skipUnless(__debug__, "Won't work if __debug__ is False")
Copy link
Contributor Author

@jackh-ncl jackh-ncl May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_mesg() @ Lib/imaplib.py:1247 is defined within a if __debug__ block, so I assume this test can be skipped when running with optimizations.

@JelleZijlstra JelleZijlstra self-assigned this May 29, 2022
@JelleZijlstra JelleZijlstra merged commit 8150b8c into python:main Jun 4, 2022
13 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jun 4, 2022

Thanks @jackh-ncl for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 4, 2022
…maplib.py` (pythonGH-93237)

(cherry picked from commit 8150b8c)

Co-authored-by: jackh-ncl <1750152+jackh-ncl@users.noreply.github.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jun 4, 2022

GH-93484 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 4, 2022
…maplib.py` (pythonGH-93237)

(cherry picked from commit 8150b8c)

Co-authored-by: jackh-ncl <1750152+jackh-ncl@users.noreply.github.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jun 4, 2022

GH-93485 is a backport of this pull request to the 3.10 branch.

miss-islington added a commit that referenced this issue Jun 4, 2022
….py` (GH-93237)

(cherry picked from commit 8150b8c)

Co-authored-by: jackh-ncl <1750152+jackh-ncl@users.noreply.github.com>
miss-islington added a commit that referenced this issue Jun 4, 2022
….py` (GH-93237)

(cherry picked from commit 8150b8c)

Co-authored-by: jackh-ncl <1750152+jackh-ncl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants