This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aeros
Recipients aeros, brett.cannon
Date 2019-08-20.03:43:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566272622.05.0.278937603321.issue37890@roundup.psfhosted.org>
In-reply-to
Content
I'm not entirely certain as to which parts should be modernized, and which ones can remain the same. A large part of my uncertainty is that there are no header comments for "test_pkg_import.py" to explain the test coverage, so I don't know if there are additional tests beyond the existing ones that should be added.

The first steps I can think of: 

1) Use ``importlib.import_module()`` instead of the built-in ``__import__()``

2) Use ``with self.assertRaises(<exception>, <msg>): ...`` instead of

```
try: __import__(self.module_name)
        except SyntaxError: pass
        else: raise RuntimeError('Failed to induce SyntaxError') # self.fail()?

...
```

3) Replace ``self.assertEqual(getattr(module, var), 1)`` with ``self.assertEqual(getattr(module, var, None), 1)`` so that AttributeErrors are not raised when unexpected behaviors occur

4) Provide useful error messages for failed assertions

I'll begin working on those, probably with a separate PR for each of them for ease of review. Let me know if there's anything else I should do, or if any of the above steps are unneeded. If I think of anything else I'll update the issue accordingly.
History
Date User Action Args
2019-08-20 03:43:42aerossetrecipients: + aeros, brett.cannon
2019-08-20 03:43:42aerossetmessageid: <1566272622.05.0.278937603321.issue37890@roundup.psfhosted.org>
2019-08-20 03:43:42aeroslinkissue37890 messages
2019-08-20 03:43:41aeroscreate