From 40d11c8197ac05a60e2289c44c3b4d8ac197c410 Mon Sep 17 00:00:00 2001 From: lzhao Date: Mon, 1 Apr 2019 16:04:10 +0800 Subject: [PATCH 1/3] bpo-31904: handle error string of ENOENT for VxWorks The strerror return "no such file or directory" when error code is ENOENT on VxWorks, this is different from Linux, change test_tabnanny.py toVxWorks excpected string. --- Lib/test/test_tabnanny.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_tabnanny.py b/Lib/test/test_tabnanny.py index 845096e63c269c..7e6616bb7821e8 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 sys import errno import tabnanny import tokenize @@ -233,8 +234,12 @@ 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 {errno.ENOENT}] " \ - f"No such file or directory: {path!r}\n" + if sys.platform == "vxworks": + err = f"{path!r}: I/O Error: [Errno {errno.ENOENT}] " \ + f"no such file or directory: {path!r}\n" + else: + 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): From ecb33059ba314c59628025bf4d47efca1863cff0 Mon Sep 17 00:00:00 2001 From: lzhao Date: Mon, 1 Apr 2019 16:08:12 +0800 Subject: [PATCH 2/3] add news file --- .../NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst diff --git a/Misc/NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst b/Misc/NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst new file mode 100644 index 00000000000000..e11ae4e29d9981 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst @@ -0,0 +1 @@ +Handle VxWorks error string of ENOENT From 0d7e91ea4bb49fa414314168fd70e0d65790bdcf Mon Sep 17 00:00:00 2001 From: lzhao Date: Wed, 17 Apr 2019 07:49:28 +0800 Subject: [PATCH 3/3] Rework test_tabnanny.py changes to use os.strerro instead of hard code string --- Lib/test/test_tabnanny.py | 11 ++++------- .../Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst | 1 - .../Tests/2019-04-01-16-06-36.bpo-31904.peaceF.rst | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst create mode 100644 Misc/NEWS.d/next/Tests/2019-04-01-16-06-36.bpo-31904.peaceF.rst diff --git a/Lib/test/test_tabnanny.py b/Lib/test/test_tabnanny.py index 7e6616bb7821e8..81549d14ae2b79 100644 --- a/Lib/test/test_tabnanny.py +++ b/Lib/test/test_tabnanny.py @@ -5,8 +5,9 @@ """ from unittest import TestCase, mock from unittest import mock -import sys import errno +import os +import sys import tabnanny import tokenize import tempfile @@ -234,12 +235,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' - if sys.platform == "vxworks": - err = f"{path!r}: I/O Error: [Errno {errno.ENOENT}] " \ - f"no such file or directory: {path!r}\n" - else: - err = f"{path!r}: I/O Error: [Errno {errno.ENOENT}] " \ - f"No such file or directory: {path!r}\n" + err = (f"{path!r}: I/O Error: [Errno {errno.ENOENT}] " + f"{os.strerror(errno.ENOENT)}: {path!r}\n") self.verify_tabnanny_check(path, err=err) def test_errored_directory(self): diff --git a/Misc/NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst b/Misc/NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst deleted file mode 100644 index e11ae4e29d9981..00000000000000 --- a/Misc/NEWS.d/next/Library/2019-04-01-16-06-36.bpo-31904.peaceF.rst +++ /dev/null @@ -1 +0,0 @@ -Handle VxWorks error string of ENOENT diff --git a/Misc/NEWS.d/next/Tests/2019-04-01-16-06-36.bpo-31904.peaceF.rst b/Misc/NEWS.d/next/Tests/2019-04-01-16-06-36.bpo-31904.peaceF.rst new file mode 100644 index 00000000000000..6297717e0fc68e --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2019-04-01-16-06-36.bpo-31904.peaceF.rst @@ -0,0 +1 @@ +Fix test_tabnanny on VxWorks: adjust ENOENT error message.