From c053a8ff631db81035fc8a27a668b6e87ed8cf43 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Tue, 28 Jan 2020 15:00:35 +0530 Subject: [PATCH 01/15] add error msg and test --- pandas/io/parsers.py | 3 +++ pandas/tests/io/parser/test_header.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 84a8b5b2a94fe..86004dcbcaf3e 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1908,6 +1908,9 @@ def __init__(self, src, **kwds): ] else: self.names = list(range(self._reader.table_width)) + elif self.prefix: + raise ValueError("Argument prefix must be None " + "if argument header is not None") # gh-9755 # diff --git a/pandas/tests/io/parser/test_header.py b/pandas/tests/io/parser/test_header.py index 7dc106ef0c186..4ba40c299d50d 100644 --- a/pandas/tests/io/parser/test_header.py +++ b/pandas/tests/io/parser/test_header.py @@ -24,6 +24,16 @@ def test_read_with_bad_header(all_parsers): parser.read_csv(s, header=[10]) +def test_read_raises_on_header_prefix(all_parsers): + parser = all_parsers + msg = ("Argument prefix must be None " + "if argument header is not None") + with pytest.raises(ValueError, match=msg): + s = StringIO("0,1\n2,3") + parser.read_csv(s, header=0, prefix = "_X") + + + def test_negative_header(all_parsers): # see gh-27779 parser = all_parsers From 071ba5b97924f07b17f782acdcfab94277c607bd Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Tue, 28 Jan 2020 15:06:41 +0530 Subject: [PATCH 02/15] run black pandas --- pandas/io/parsers.py | 5 +++-- pandas/tests/io/parser/test_header.py | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 86004dcbcaf3e..82efc73918d54 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1909,8 +1909,9 @@ def __init__(self, src, **kwds): else: self.names = list(range(self._reader.table_width)) elif self.prefix: - raise ValueError("Argument prefix must be None " - "if argument header is not None") + raise ValueError( + "Argument prefix must be None " "if argument header is not None" + ) # gh-9755 # diff --git a/pandas/tests/io/parser/test_header.py b/pandas/tests/io/parser/test_header.py index 4ba40c299d50d..c5c895bb4cd02 100644 --- a/pandas/tests/io/parser/test_header.py +++ b/pandas/tests/io/parser/test_header.py @@ -26,12 +26,10 @@ def test_read_with_bad_header(all_parsers): def test_read_raises_on_header_prefix(all_parsers): parser = all_parsers - msg = ("Argument prefix must be None " - "if argument header is not None") + msg = "Argument prefix must be None " "if argument header is not None" with pytest.raises(ValueError, match=msg): s = StringIO("0,1\n2,3") - parser.read_csv(s, header=0, prefix = "_X") - + parser.read_csv(s, header=0, prefix="_X") def test_negative_header(all_parsers): From ed8278ecedae08f92836c555b217c4928de61615 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Tue, 28 Jan 2020 15:09:15 +0530 Subject: [PATCH 03/15] remove extra quotes --- pandas/io/parsers.py | 2 +- pandas/tests/io/parser/test_header.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 82efc73918d54..8be131e589a7c 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1910,7 +1910,7 @@ def __init__(self, src, **kwds): self.names = list(range(self._reader.table_width)) elif self.prefix: raise ValueError( - "Argument prefix must be None " "if argument header is not None" + "Argument prefix must be None if argument header is not None" ) # gh-9755 diff --git a/pandas/tests/io/parser/test_header.py b/pandas/tests/io/parser/test_header.py index c5c895bb4cd02..34d4b05555005 100644 --- a/pandas/tests/io/parser/test_header.py +++ b/pandas/tests/io/parser/test_header.py @@ -26,7 +26,7 @@ def test_read_with_bad_header(all_parsers): def test_read_raises_on_header_prefix(all_parsers): parser = all_parsers - msg = "Argument prefix must be None " "if argument header is not None" + msg = "Argument prefix must be None if argument header is not None" with pytest.raises(ValueError, match=msg): s = StringIO("0,1\n2,3") parser.read_csv(s, header=0, prefix="_X") From 7231f52d4fefc4d1be48890c7ab2fcda31796dbe Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Tue, 28 Jan 2020 19:35:28 +0530 Subject: [PATCH 04/15] change location of the test --- pandas/tests/frame/test_to_csv.py | 6 ++++++ pandas/tests/io/parser/test_header.py | 8 -------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pandas/tests/frame/test_to_csv.py b/pandas/tests/frame/test_to_csv.py index aeff92971b42a..a511f2510f7b1 100644 --- a/pandas/tests/frame/test_to_csv.py +++ b/pandas/tests/frame/test_to_csv.py @@ -575,6 +575,12 @@ def test_to_csv_headers(self): recons.reset_index(inplace=True) tm.assert_frame_equal(to_df, recons) + def test_to_csv_raises_on_header_prefix(): + msg = "Argument prefix must be None if argument header is not None" + with pytest.raises(ValueError, match=msg): + s = StringIO("0,1\n2,3") + read_csv(s, header=0, prefix="_X") + def test_to_csv_multiindex(self, float_frame, datetime_frame): frame = float_frame diff --git a/pandas/tests/io/parser/test_header.py b/pandas/tests/io/parser/test_header.py index 34d4b05555005..7dc106ef0c186 100644 --- a/pandas/tests/io/parser/test_header.py +++ b/pandas/tests/io/parser/test_header.py @@ -24,14 +24,6 @@ def test_read_with_bad_header(all_parsers): parser.read_csv(s, header=[10]) -def test_read_raises_on_header_prefix(all_parsers): - parser = all_parsers - msg = "Argument prefix must be None if argument header is not None" - with pytest.raises(ValueError, match=msg): - s = StringIO("0,1\n2,3") - parser.read_csv(s, header=0, prefix="_X") - - def test_negative_header(all_parsers): # see gh-27779 parser = all_parsers From a5fb1075a4aaee0b19e0e39ecd51cee65f51c1d8 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Tue, 28 Jan 2020 19:56:30 +0530 Subject: [PATCH 05/15] add whatsnew --- doc/source/whatsnew/v1.1.0.rst | 2 +- pandas/tests/frame/test_to_csv.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index d0644fbb7ef54..4ee6b70f376c9 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -162,7 +162,7 @@ MultiIndex I/O ^^^ - Bug in :meth:`read_json` where integer overflow was occuring when json contains big number strings. (:issue:`30320`) -- +- `read_csv` will now raise a ``ValueError`` when arguments `header` and `prefix` both are not None. (:issue:`27394`) - Plotting diff --git a/pandas/tests/frame/test_to_csv.py b/pandas/tests/frame/test_to_csv.py index a511f2510f7b1..73e0c78fc2111 100644 --- a/pandas/tests/frame/test_to_csv.py +++ b/pandas/tests/frame/test_to_csv.py @@ -575,10 +575,10 @@ def test_to_csv_headers(self): recons.reset_index(inplace=True) tm.assert_frame_equal(to_df, recons) - def test_to_csv_raises_on_header_prefix(): + def test_to_csv_raises_on_header_prefix(self): msg = "Argument prefix must be None if argument header is not None" + s = StringIO("0,1\n2,3") with pytest.raises(ValueError, match=msg): - s = StringIO("0,1\n2,3") read_csv(s, header=0, prefix="_X") def test_to_csv_multiindex(self, float_frame, datetime_frame): From 13d8644806f12d34230912b049ec0b2562c849d4 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Tue, 28 Jan 2020 20:00:25 +0530 Subject: [PATCH 06/15] add gh --- pandas/tests/frame/test_to_csv.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/frame/test_to_csv.py b/pandas/tests/frame/test_to_csv.py index 73e0c78fc2111..db26ccbbeefd7 100644 --- a/pandas/tests/frame/test_to_csv.py +++ b/pandas/tests/frame/test_to_csv.py @@ -576,6 +576,7 @@ def test_to_csv_headers(self): tm.assert_frame_equal(to_df, recons) def test_to_csv_raises_on_header_prefix(self): + # gh-27394 msg = "Argument prefix must be None if argument header is not None" s = StringIO("0,1\n2,3") with pytest.raises(ValueError, match=msg): From a003c510024dc8b25521f132e7f053ef19168d31 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Fri, 31 Jan 2020 23:03:30 +0530 Subject: [PATCH 07/15] change position of the raise --- pandas/io/parsers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 8be131e589a7c..3c3353c7dd189 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1888,6 +1888,10 @@ def __init__(self, src, **kwds): if self._reader.header is None: self.names = None else: + if self.prefix: + raise ValueError( + "Argument prefix must be None if argument header is not None" + ) if len(self._reader.header) > 1: # we have a multi index in the columns ( @@ -1908,10 +1912,6 @@ def __init__(self, src, **kwds): ] else: self.names = list(range(self._reader.table_width)) - elif self.prefix: - raise ValueError( - "Argument prefix must be None if argument header is not None" - ) # gh-9755 # From 77c8ee0258e026165eacfc1512c6d04b0bee5704 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Sat, 1 Feb 2020 13:10:43 +0530 Subject: [PATCH 08/15] change the location of the test --- pandas/tests/frame/test_to_csv.py | 2 +- pandas/tests/io/parser/test_common.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pandas/tests/frame/test_to_csv.py b/pandas/tests/frame/test_to_csv.py index db26ccbbeefd7..107baa601f6f4 100644 --- a/pandas/tests/frame/test_to_csv.py +++ b/pandas/tests/frame/test_to_csv.py @@ -575,7 +575,7 @@ def test_to_csv_headers(self): recons.reset_index(inplace=True) tm.assert_frame_equal(to_df, recons) - def test_to_csv_raises_on_header_prefix(self): + def test_read_csv_raises_on_header_prefix(self): # gh-27394 msg = "Argument prefix must be None if argument header is not None" s = StringIO("0,1\n2,3") diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index 6c17f40b790ac..8e66f8a300145 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -16,7 +16,16 @@ from pandas._libs.tslib import Timestamp from pandas.errors import DtypeWarning, EmptyDataError, ParserError -from pandas import DataFrame, Index, MultiIndex, Series, compat, concat +from pandas import ( + DataFrame, + Index, + MultiIndex, + Series, + compat, + concat, + read_csv, +) + import pandas._testing as tm from pandas.io.parsers import CParserWrapper, TextFileReader, TextParser @@ -2040,6 +2049,14 @@ def test_read_csv_memory_growth_chunksize(all_parsers): pass +def test_read_csv_raises_on_header_prefix(): + # gh-27394 + msg = "Argument prefix must be None if argument header is not None" + s = StringIO("0,1\n2,3") + with pytest.raises(ValueError, match=msg): + read_csv(s, header=0, prefix="_X") + + def test_read_table_equivalency_to_read_csv(all_parsers): # see gh-21948 # As of 0.25.0, read_table is undeprecated From 39cd6d54946e3a8969213d49cf7a92c238a87297 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Sat, 1 Feb 2020 16:20:33 +0530 Subject: [PATCH 09/15] sort imports --- pandas/tests/frame/test_to_csv.py | 6 ------ pandas/tests/io/parser/test_common.py | 1 - 2 files changed, 7 deletions(-) diff --git a/pandas/tests/frame/test_to_csv.py b/pandas/tests/frame/test_to_csv.py index 107baa601f6f4..2357407d243a4 100644 --- a/pandas/tests/frame/test_to_csv.py +++ b/pandas/tests/frame/test_to_csv.py @@ -575,12 +575,6 @@ def test_to_csv_headers(self): recons.reset_index(inplace=True) tm.assert_frame_equal(to_df, recons) - def test_read_csv_raises_on_header_prefix(self): - # gh-27394 - msg = "Argument prefix must be None if argument header is not None" - s = StringIO("0,1\n2,3") - with pytest.raises(ValueError, match=msg): - read_csv(s, header=0, prefix="_X") def test_to_csv_multiindex(self, float_frame, datetime_frame): diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index 8e66f8a300145..6f64ad4c114ce 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -25,7 +25,6 @@ concat, read_csv, ) - import pandas._testing as tm from pandas.io.parsers import CParserWrapper, TextFileReader, TextParser From a2cb6a41d44145495f33404d005570e3ff7c5092 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Sat, 1 Feb 2020 16:54:31 +0530 Subject: [PATCH 10/15] use isort --- pandas/tests/frame/test_to_csv.py | 1 - pandas/tests/io/parser/test_common.py | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pandas/tests/frame/test_to_csv.py b/pandas/tests/frame/test_to_csv.py index 2357407d243a4..aeff92971b42a 100644 --- a/pandas/tests/frame/test_to_csv.py +++ b/pandas/tests/frame/test_to_csv.py @@ -575,7 +575,6 @@ def test_to_csv_headers(self): recons.reset_index(inplace=True) tm.assert_frame_equal(to_df, recons) - def test_to_csv_multiindex(self, float_frame, datetime_frame): frame = float_frame diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index 6f64ad4c114ce..5e37b0dade263 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -16,15 +16,7 @@ from pandas._libs.tslib import Timestamp from pandas.errors import DtypeWarning, EmptyDataError, ParserError -from pandas import ( - DataFrame, - Index, - MultiIndex, - Series, - compat, - concat, - read_csv, -) +from pandas import DataFrame, Index, MultiIndex, Series, compat, concat, read_csv import pandas._testing as tm from pandas.io.parsers import CParserWrapper, TextFileReader, TextParser From 204dbc27d31f38ad54c0d1511f16bd11c2492b42 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Sun, 2 Feb 2020 11:07:02 +0530 Subject: [PATCH 11/15] add the check in ParserBase --- pandas/io/parsers.py | 29 ++++++++++++++------------- pandas/tests/io/parser/test_common.py | 7 ++++--- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 3c3353c7dd189..2f5a26c97fa78 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1400,16 +1400,21 @@ def __init__(self, kwds): "when specifying a multi-index header" ) - # GH 16338 - elif self.header is not None and not is_integer(self.header): - raise ValueError("header must be integer or list of integers") - - # GH 27779 - elif self.header is not None and self.header < 0: - raise ValueError( - "Passing negative integer to header is invalid. " - "For no header, use header=None instead" - ) + elif self.header: + # GH 16338 + if not is_integer(self.header): + raise ValueError("header must be integer or list of integers") + # GH 27394 + elif self.prefix: + raise ValueError( + "Argument prefix must be None if argument header is not None" + ) + # GH 27779 + elif self.header < 0: + raise ValueError( + "Passing negative integer to header is invalid. " + "For no header, use header=None instead" + ) self._name_processed = False @@ -1888,10 +1893,6 @@ def __init__(self, src, **kwds): if self._reader.header is None: self.names = None else: - if self.prefix: - raise ValueError( - "Argument prefix must be None if argument header is not None" - ) if len(self._reader.header) > 1: # we have a multi index in the columns ( diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index 5e37b0dade263..32f684b938d51 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -2040,12 +2040,13 @@ def test_read_csv_memory_growth_chunksize(all_parsers): pass -def test_read_csv_raises_on_header_prefix(): +def test_read_csv_raises_on_header_prefix(all_parsers): # gh-27394 - msg = "Argument prefix must be None if argument header is not None" + parser = all_parsers + msg = ("Argument prefix must be None if argument header is not None") s = StringIO("0,1\n2,3") with pytest.raises(ValueError, match=msg): - read_csv(s, header=0, prefix="_X") + parser.read_csv(s, header=0, prefix = "_X") def test_read_table_equivalency_to_read_csv(all_parsers): From 1bc350bd259421d02a5e496dd8ac29f259f0102c Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Sun, 2 Feb 2020 12:24:59 +0530 Subject: [PATCH 12/15] add a None constraint --- pandas/io/parsers.py | 5 ++--- pandas/tests/io/parser/test_common.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 2f5a26c97fa78..ccdc3118bbbf1 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1399,13 +1399,12 @@ def __init__(self, kwds): "index_col must only contain row numbers " "when specifying a multi-index header" ) - - elif self.header: + elif self.header is not None: # GH 16338 if not is_integer(self.header): raise ValueError("header must be integer or list of integers") # GH 27394 - elif self.prefix: + elif self.prefix is not None: raise ValueError( "Argument prefix must be None if argument header is not None" ) diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index 32f684b938d51..bcb3b53c54478 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -2046,7 +2046,7 @@ def test_read_csv_raises_on_header_prefix(all_parsers): msg = ("Argument prefix must be None if argument header is not None") s = StringIO("0,1\n2,3") with pytest.raises(ValueError, match=msg): - parser.read_csv(s, header=0, prefix = "_X") + parser.read_csv(s, header=0, prefix="_X") def test_read_table_equivalency_to_read_csv(all_parsers): From a03d5b56b9a674bdd25568c0e33e8213e12a511c Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Sun, 2 Feb 2020 12:52:02 +0530 Subject: [PATCH 13/15] remove import read_csv --- pandas/tests/io/parser/test_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index bcb3b53c54478..9454eec6f6eb9 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -16,7 +16,7 @@ from pandas._libs.tslib import Timestamp from pandas.errors import DtypeWarning, EmptyDataError, ParserError -from pandas import DataFrame, Index, MultiIndex, Series, compat, concat, read_csv +from pandas import DataFrame, Index, MultiIndex, Series, compat, concat import pandas._testing as tm from pandas.io.parsers import CParserWrapper, TextFileReader, TextParser From cc1f6f826b1982c78eda260c0e3b011e4b645ec3 Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Sun, 2 Feb 2020 12:55:43 +0530 Subject: [PATCH 14/15] make requested changes --- pandas/io/parsers.py | 8 ++++---- pandas/tests/io/parser/test_common.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index ccdc3118bbbf1..b4177213d6a65 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1400,14 +1400,14 @@ def __init__(self, kwds): "when specifying a multi-index header" ) elif self.header is not None: - # GH 16338 - if not is_integer(self.header): - raise ValueError("header must be integer or list of integers") # GH 27394 - elif self.prefix is not None: + if self.prefix is not None: raise ValueError( "Argument prefix must be None if argument header is not None" ) + # GH 16338 + elif not is_integer(self.header): + raise ValueError("header must be integer or list of integers") # GH 27779 elif self.header < 0: raise ValueError( diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index 9454eec6f6eb9..ef04c4ede7b19 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -2043,7 +2043,7 @@ def test_read_csv_memory_growth_chunksize(all_parsers): def test_read_csv_raises_on_header_prefix(all_parsers): # gh-27394 parser = all_parsers - msg = ("Argument prefix must be None if argument header is not None") + msg = "Argument prefix must be None if argument header is not None" s = StringIO("0,1\n2,3") with pytest.raises(ValueError, match=msg): parser.read_csv(s, header=0, prefix="_X") From d962941c1d41d49dae7ab526ddec52b8f71ed58c Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Mon, 3 Feb 2020 14:53:36 +0530 Subject: [PATCH 15/15] make requested changes --- doc/source/whatsnew/v1.1.0.rst | 2 +- pandas/tests/io/parser/test_common.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index ff96a6b374af0..4412b35da32a8 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -168,7 +168,7 @@ MultiIndex I/O ^^^ - Bug in :meth:`read_json` where integer overflow was occuring when json contains big number strings. (:issue:`30320`) -- `read_csv` will now raise a ``ValueError`` when arguments `header` and `prefix` both are not None. (:issue:`27394`) +- `read_csv` will now raise a ``ValueError`` when the arguments `header` and `prefix` both are not `None`. (:issue:`27394`) - Plotting diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index ef04c4ede7b19..c19056d434ec3 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -2044,7 +2044,9 @@ def test_read_csv_raises_on_header_prefix(all_parsers): # gh-27394 parser = all_parsers msg = "Argument prefix must be None if argument header is not None" + s = StringIO("0,1\n2,3") + with pytest.raises(ValueError, match=msg): parser.read_csv(s, header=0, prefix="_X")