python 3.12.5 source install make test test_smtplib FAIL test_with_statement AND test_with_statement_QUIT_failure Connection unexpectedly closed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
Update: This describes the problem, analysis and suggested fix. Can someone modify the source test code as indicated?
Rocky 9 LINUX
make test
ERROR
======================================================================
ERROR: test_with_statement (test.test_smtplib.SMTPSimTests.test_with_statement)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/defuser/Downloads/Python-3.12.5/Lib/test/test_smtplib.py", line 1231, in test_with_statement
code, message = smtp.noop()
^^^^^^^^^^^
...
======================================================================
ERROR: test_with_statement_QUIT_failure (test.test_smtplib.SMTPSimTests.test_with_statement_QUIT_failure)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/defuser/Downloads/Python-3.12.5/Lib/test/test_smtplib.py", line 1241, in test_with_statement_QUIT_failure
smtp.noop()
cd /home/defuser/Downloads/Python-3.12.5/Lib/test
vi test_smtplib.py
search for (one is right before the other)
test_with_statement
test_with_statement_QUIT_failure
note
with smtplib.SMTP(HOST, self.port, 'localhost') as smtp:
python with explanation, see https://www.geeksforgeeks.org/with-statement-in-python/
IN ANOTHER TERMINAL
cd ~/Downloads/Python-3.12.5
find . -name "smtplib*"
./Doc/library/smtplib.rst
./Lib/smtplib.py
./Lib/__pycache__/smtplib.cpython-312.pyc
view ./Lib/smtplib.py
search for
class SMTP
note this class meets "with" requirements in https://www.geeksforgeeks.org/with-statement-in-python/
def __init__(self, host='', port=0, local_hostname=None,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None):
RETURN to TERMINAL "vi test_smtplib.py"
SMTP class instantiations (see test_quit_resets_greeting) use
smtp = smtplib.SMTP(HOST, self.port,
local_hostname='localhost' ...)
It is PROBABLY improper to use 'local_hostname=None' in "with" statement.
SOLUTION
In methods test_with_statement and test_with_statement_QUIT_failure
change
with smtplib.SMTP(HOST, self.port) as smtp:
to
with smtplib.SMTP(HOST, self.port, 'localhost') as smtp:
make test will now work
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Lib/test/test_smtplib.py at SMTPSimTests.test_with_statement and test_with_statement_QUIT_failure, comparing their SMTP construction with test_quit_resets_greeting. Run those tests or make test after checking the proposed localhost argument; done means both reported failures pass on Python 3.12.5.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100