Message349985
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. |
|
Date |
User |
Action |
Args |
2019-08-20 03:43:42 | aeros | set | recipients:
+ aeros, brett.cannon |
2019-08-20 03:43:42 | aeros | set | messageid: <1566272622.05.0.278937603321.issue37890@roundup.psfhosted.org> |
2019-08-20 03:43:42 | aeros | link | issue37890 messages |
2019-08-20 03:43:41 | aeros | create | |
|