Kyle Stanley <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37890>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com