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

test_mailbox: Duplicate keys in _sample_headers cause _check_sample to only test one value #93121

Open
The-Compiler opened this issue May 23, 2022 · 0 comments
Labels
expert-email tests type-bug

Comments

@The-Compiler
Copy link
Contributor

@The-Compiler The-Compiler commented May 23, 2022

Bug report

A sample of mail headers is used in tests here:

for key, value in _sample_headers.items():
self.assertIn(value, msg.get_all(key))

However, _sample_headers is defined as a dict, despite having duplicate keys, such as Received:

_sample_headers = {
"Return-Path":"<gkj@gregorykjohnson.com>",
"X-Original-To":"gkj+person@localhost",
"Delivered-To":"gkj+person@localhost",
"Received":"""from localhost (localhost [127.0.0.1])
by andy.gregorykjohnson.com (Postfix) with ESMTP id 356ED9DD17
for <gkj+person@localhost>; Wed, 13 Jul 2005 17:23:16 -0400 (EDT)""",
"Delivered-To":"gkj@sundance.gregorykjohnson.com",
"Received":"""from localhost [127.0.0.1]
by localhost with POP3 (fetchmail-6.2.5)
for gkj+person@localhost (single-drop); Wed, 13 Jul 2005 17:23:16 -0400 (EDT)""",
"Received":"""from andy.gregorykjohnson.com (andy.gregorykjohnson.com [64.32.235.228])
by sundance.gregorykjohnson.com (Postfix) with ESMTP id 5B056316746
for <gkj@gregorykjohnson.com>; Wed, 13 Jul 2005 17:23:11 -0400 (EDT)""",
"Received":"""by andy.gregorykjohnson.com (Postfix, from userid 1000)
id 490CD9DD17; Wed, 13 Jul 2005 17:23:11 -0400 (EDT)""",
"Date":"Wed, 13 Jul 2005 17:23:11 -0400",
"From":""""Gregory K. Johnson" <gkj@gregorykjohnson.com>""",
"To":"gkj@gregorykjohnson.com",
"Subject":"Sample message",
"Mime-Version":"1.0",
"Content-Type":"""multipart/mixed; boundary="NMuMz9nt05w80d4+\"""",
"Content-Disposition":"inline",
"User-Agent": "Mutt/1.5.9i" }

causing those tests to only check one of those values. It should probably be a list of tuples instead? If this is indeed unintended, I'd be happy to open a PR.

cc @warsaw

(Found by running flake8 over Lib/ out of curiosity, see #93010 (comment))

Your environment

  • CPython versions tested on: Seems to be around since ~forever, added to the git repo in 477c8d5.
  • Operating system and architecture: Archlinux x86_64
@The-Compiler The-Compiler added the type-bug label May 23, 2022
@AA-Turner AA-Turner added tests expert-email labels May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expert-email tests type-bug
Projects
None yet
Development

No branches or pull requests

2 participants