]> granicus.if.org Git - python/commitdiff
closes bpo-34594: Don't hardcode errno values in the tests. (GH-9076)
authorZackery Spytz <zspytz@gmail.com>
Thu, 6 Sep 2018 18:43:30 +0000 (12:43 -0600)
committerBenjamin Peterson <benjamin@python.org>
Thu, 6 Sep 2018 18:43:30 +0000 (11:43 -0700)
Lib/test/test_spwd.py
Lib/test/test_tabnanny.py
Misc/NEWS.d/next/Tests/2018-09-05-23-50-21.bpo-34594.tqL-GS.rst [new file with mode: 0644]

index e893f3a847fdf9032ca908f73a5c80adea0c045e..07793c84c8e912c5d09bff0e05884a8dc69a42f6 100644 (file)
@@ -67,8 +67,6 @@ class TestSpwdNonRoot(unittest.TestCase):
                 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__":
index ec887361730b96e3874781bf838c5094e61a41bd..845096e63c269ce47ce061e289164e541e483af0 100644 (file)
@@ -5,6 +5,7 @@ Glossary:
 """
 from unittest import TestCase, mock
 from unittest import mock
+import errno
 import tabnanny
 import tokenize
 import tempfile
@@ -232,7 +233,8 @@ class TestCheck(TestCase):
     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 (file)
index 0000000..7a7b1f0
--- /dev/null
@@ -0,0 +1 @@
+Fix usage of hardcoded ``errno`` values in the tests.