[Python-checkins] closes bpo-34594: Don't hardcode errno values in the tests. (GH-9076)

Benjamin Peterson webhook-mailer at python.org
Thu Sep 6 14:43:41 EDT 2018


https://github.com/python/cpython/commit/b03c2c51909e3b5b5966d86a2829b5ddf2d496aa
commit: b03c2c51909e3b5b5966d86a2829b5ddf2d496aa
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: Benjamin Peterson <benjamin at python.org>
date: 2018-09-06T11:43:30-07:00
summary:

closes bpo-34594: Don't hardcode errno values in the tests. (GH-9076)

files:
A Misc/NEWS.d/next/Tests/2018-09-05-23-50-21.bpo-34594.tqL-GS.rst
M Lib/test/test_spwd.py
M Lib/test/test_tabnanny.py

diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
index e893f3a847fd..07793c84c8e9 100644
--- a/Lib/test/test_spwd.py
+++ b/Lib/test/test_spwd.py
@@ -67,8 +67,6 @@ def test_getspnam_exception(self):
                 spwd.getspnam(name)
         except KeyError as exc:
             self.skipTest("spwd entry %r doesn't exist: %s" % (name, exc))
-        else:
-            self.assertEqual(str(cm.exception), '[Errno 13] Permission denied')
 
 
 if __name__ == "__main__":
diff --git a/Lib/test/test_tabnanny.py b/Lib/test/test_tabnanny.py
index ec887361730b..845096e63c26 100644
--- a/Lib/test/test_tabnanny.py
+++ b/Lib/test/test_tabnanny.py
@@ -5,6 +5,7 @@
 """
 from unittest import TestCase, mock
 from unittest import mock
+import errno
 import tabnanny
 import tokenize
 import tempfile
@@ -232,7 +233,8 @@ def test_when_nannynag_error(self):
     def test_when_no_file(self):
         """A python file which does not exist actually in system."""
         path = 'no_file.py'
-        err = f"{path!r}: I/O Error: [Errno 2] No such file or directory: {path!r}\n"
+        err = f"{path!r}: I/O Error: [Errno {errno.ENOENT}] " \
+              f"No such file or directory: {path!r}\n"
         self.verify_tabnanny_check(path, err=err)
 
     def test_errored_directory(self):
diff --git a/Misc/NEWS.d/next/Tests/2018-09-05-23-50-21.bpo-34594.tqL-GS.rst b/Misc/NEWS.d/next/Tests/2018-09-05-23-50-21.bpo-34594.tqL-GS.rst
new file mode 100644
index 000000000000..7a7b1f055561
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2018-09-05-23-50-21.bpo-34594.tqL-GS.rst
@@ -0,0 +1 @@
+Fix usage of hardcoded ``errno`` values in the tests.



More information about the Python-checkins mailing list