From 0d9364b2c5ec8047a09942973abe2de8d2301850 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Sun, 19 Jan 2020 14:14:19 +0000 Subject: [PATCH 1/7] TST: Check for pyarrow before pyarrow.feather tests (read_/to_feather can only use pyarrow.feather, not feather-format feather) --- pandas/tests/io/test_common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 22aa78919ef0f..a0bf41de10b45 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -129,7 +129,7 @@ def test_iterator(self): (pd.read_csv, "os", FileNotFoundError, "csv"), (pd.read_fwf, "os", FileNotFoundError, "txt"), (pd.read_excel, "xlrd", FileNotFoundError, "xlsx"), - (pd.read_feather, "feather", Exception, "feather"), + (pd.read_feather, "pyarrow", Exception, "feather"), (pd.read_hdf, "tables", FileNotFoundError, "h5"), (pd.read_stata, "os", FileNotFoundError, "dta"), (pd.read_sas, "os", FileNotFoundError, "sas7bdat"), @@ -165,7 +165,7 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext): (pd.read_table, "os", FileNotFoundError, "csv"), (pd.read_fwf, "os", FileNotFoundError, "txt"), (pd.read_excel, "xlrd", FileNotFoundError, "xlsx"), - (pd.read_feather, "feather", Exception, "feather"), + (pd.read_feather, "pyarrow", Exception, "feather"), (pd.read_hdf, "tables", FileNotFoundError, "h5"), (pd.read_stata, "os", FileNotFoundError, "dta"), (pd.read_sas, "os", FileNotFoundError, "sas7bdat"), @@ -212,7 +212,7 @@ def test_read_expands_user_home_dir( (pd.read_excel, "xlrd", ("io", "data", "excel", "test1.xlsx")), ( pd.read_feather, - "feather", + "pyarrow", ("io", "data", "feather", "feather-0_3_1.feather"), ), ( @@ -249,7 +249,7 @@ def test_read_fspath_all(self, reader, module, path, datapath): [ ("to_csv", {}, "os"), ("to_excel", {"engine": "xlwt"}, "xlwt"), - ("to_feather", {}, "feather"), + ("to_feather", {}, "pyarrow"), ("to_html", {}, "os"), ("to_json", {}, "os"), ("to_latex", {}, "os"), From b939900d48bed8ecec761b54cfa10f5c7b84de0a Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Sun, 19 Jan 2020 21:34:31 +0000 Subject: [PATCH 2/7] TST: when checking for a nonexistent file error, accept pyarrow's error format --- pandas/tests/io/test_common.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index a0bf41de10b45..846150155e5b0 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -153,8 +153,13 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext): msg7 = ( fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'" ) + msg8 = ( + fr"Failed to open local file '.+does_not_exist\.{fn_ext}'," + fr" error: No such file or directory" + ) + with pytest.raises( - error_class, match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7})" + error_class, match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})" ): reader(path) @@ -193,9 +198,13 @@ def test_read_expands_user_home_dir( msg7 = ( fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'" ) + msg8 = ( + fr"Failed to open local file '.+does_not_exist\.{fn_ext}'," + fr" error: No such file or directory" + ) with pytest.raises( - error_class, match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7})" + error_class, match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})" ): reader(path) From 196e8657a15f88b7d85c6f3166f6687bb01f109b Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Mon, 20 Jan 2020 19:18:14 +0000 Subject: [PATCH 3/7] TST: check for IOError from pyarrow and not for quotes, linting --- pandas/tests/io/test_common.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 846150155e5b0..c0ea981601ab4 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -129,7 +129,7 @@ def test_iterator(self): (pd.read_csv, "os", FileNotFoundError, "csv"), (pd.read_fwf, "os", FileNotFoundError, "txt"), (pd.read_excel, "xlrd", FileNotFoundError, "xlsx"), - (pd.read_feather, "pyarrow", Exception, "feather"), + (pd.read_feather, "pyarrow", IOError, "feather"), (pd.read_hdf, "tables", FileNotFoundError, "h5"), (pd.read_stata, "os", FileNotFoundError, "dta"), (pd.read_sas, "os", FileNotFoundError, "sas7bdat"), @@ -154,12 +154,12 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext): fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'" ) msg8 = ( - fr"Failed to open local file '.+does_not_exist\.{fn_ext}'," + fr"Failed to open local file .+does_not_exist\.{fn_ext}.?," fr" error: No such file or directory" ) - with pytest.raises( - error_class, match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})" + with pytest.raises(error_class, match= + fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})" ): reader(path) @@ -170,7 +170,7 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext): (pd.read_table, "os", FileNotFoundError, "csv"), (pd.read_fwf, "os", FileNotFoundError, "txt"), (pd.read_excel, "xlrd", FileNotFoundError, "xlsx"), - (pd.read_feather, "pyarrow", Exception, "feather"), + (pd.read_feather, "pyarrow", IOError, "feather"), (pd.read_hdf, "tables", FileNotFoundError, "h5"), (pd.read_stata, "os", FileNotFoundError, "dta"), (pd.read_sas, "os", FileNotFoundError, "sas7bdat"), @@ -199,12 +199,12 @@ def test_read_expands_user_home_dir( fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'" ) msg8 = ( - fr"Failed to open local file '.+does_not_exist\.{fn_ext}'," + fr"Failed to open local file .+does_not_exist\.{fn_ext}.?," fr" error: No such file or directory" ) - with pytest.raises( - error_class, match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})" + with pytest.raises(error_class, match= + fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})" ): reader(path) From d8f7664d97b689fec59a29e54e7a8ac04717a001 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Mon, 20 Jan 2020 22:37:10 +0000 Subject: [PATCH 4/7] more linting --- pandas/tests/io/test_common.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index c0ea981601ab4..59127aa8532f0 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -158,9 +158,10 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext): fr" error: No such file or directory" ) - with pytest.raises(error_class, match= - fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})" - ): + with pytest.raises(error_class, + match=(fr"({msg1}|{msg2}|{msg3}|{msg4}" + fr"|{msg5}|{msg6}|{msg7}|{msg8})") + ): reader(path) @pytest.mark.parametrize( @@ -203,9 +204,10 @@ def test_read_expands_user_home_dir( fr" error: No such file or directory" ) - with pytest.raises(error_class, match= - fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})" - ): + with pytest.raises(error_class, + match=(fr"({msg1}|{msg2}|{msg3}|{msg4}" + fr"|{msg5}|{msg6}|{msg7}|{msg8})") + ): reader(path) @pytest.mark.parametrize( From 938bc4a002228e52f7a5b398ef3ee01c9bee8786 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Tue, 21 Jan 2020 07:48:12 +0000 Subject: [PATCH 5/7] linting --- pandas/tests/io/test_common.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 59127aa8532f0..b276998ddf924 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -158,10 +158,10 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext): fr" error: No such file or directory" ) - with pytest.raises(error_class, - match=(fr"({msg1}|{msg2}|{msg3}|{msg4}" - fr"|{msg5}|{msg6}|{msg7}|{msg8})") - ): + with pytest.raises( + error_class, + match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})", + ): reader(path) @pytest.mark.parametrize( @@ -204,10 +204,10 @@ def test_read_expands_user_home_dir( fr" error: No such file or directory" ) - with pytest.raises(error_class, - match=(fr"({msg1}|{msg2}|{msg3}|{msg4}" - fr"|{msg5}|{msg6}|{msg7}|{msg8})") - ): + with pytest.raises( + error_class, + match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})", + ): reader(path) @pytest.mark.parametrize( From 788f92b00c92a5dc143f17d61aa0df36e1202bf1 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Tue, 21 Jan 2020 21:43:52 +0000 Subject: [PATCH 6/7] TST: accept other versions of pyarrow error message --- pandas/tests/io/test_common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index b276998ddf924..136f6ff026857 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -154,8 +154,8 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext): fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'" ) msg8 = ( - fr"Failed to open local file .+does_not_exist\.{fn_ext}.?," - fr" error: No such file or directory" + fr"Failed to open local file.+does_not_exist\.{fn_ext}.?," + fr" error: .*" ) with pytest.raises( @@ -200,8 +200,8 @@ def test_read_expands_user_home_dir( fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'" ) msg8 = ( - fr"Failed to open local file .+does_not_exist\.{fn_ext}.?," - fr" error: No such file or directory" + fr"Failed to open local file.+does_not_exist\.{fn_ext}.?," + fr" error: .*" ) with pytest.raises( From c6ca500af10d4adb5b095e050c9338a282501278 Mon Sep 17 00:00:00 2001 From: "Rebecca N. Palmer" Date: Tue, 21 Jan 2020 22:10:54 +0000 Subject: [PATCH 7/7] linting --- pandas/tests/io/test_common.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 136f6ff026857..d7a21b27308e8 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -153,10 +153,7 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext): msg7 = ( fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'" ) - msg8 = ( - fr"Failed to open local file.+does_not_exist\.{fn_ext}.?," - fr" error: .*" - ) + msg8 = fr"Failed to open local file.+does_not_exist\.{fn_ext}.?, error: .*" with pytest.raises( error_class, @@ -199,10 +196,7 @@ def test_read_expands_user_home_dir( msg7 = ( fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'" ) - msg8 = ( - fr"Failed to open local file.+does_not_exist\.{fn_ext}.?," - fr" error: .*" - ) + msg8 = fr"Failed to open local file.+does_not_exist\.{fn_ext}.?, error: .*" with pytest.raises( error_class,