@@ -229,17 +229,20 @@ def test_chunks_have_consistent_numerical_type(all_parsers, monkeypatch):
229229 assert result .a .dtype == float
230230
231231
232- def test_warn_if_chunks_have_mismatched_type (all_parsers , using_infer_string ):
232+ def test_warn_if_chunks_have_mismatched_type (
233+ all_parsers , using_infer_string , monkeypatch
234+ ):
233235 warning_type = None
234236 parser = all_parsers
235- size = 10000
237+ heuristic = 2 ** 3
238+ size = 10
236239
237240 # see gh-3866: if chunks are different types and can't
238241 # be coerced using numerical types, then issue warning.
239242 if parser .engine == "c" and parser .low_memory :
240243 warning_type = DtypeWarning
241244 # Use larger size to hit warning path
242- size = 499999
245+ size = heuristic - 1
243246
244247 integers = [str (i ) for i in range (size )]
245248 data = "a\n " + "\n " .join (integers + ["a" , "b" ] + integers )
@@ -251,12 +254,14 @@ def test_warn_if_chunks_have_mismatched_type(all_parsers, using_infer_string):
251254 buf ,
252255 )
253256 else :
254- df = parser .read_csv_check_warnings (
255- warning_type ,
256- r"Columns \(0: a\) have mixed types. "
257- "Specify dtype option on import or set low_memory=False." ,
258- buf ,
259- )
257+ with monkeypatch .context () as m :
258+ m .setattr (libparsers , "DEFAULT_BUFFER_HEURISTIC" , heuristic )
259+ df = parser .read_csv_check_warnings (
260+ warning_type ,
261+ r"Columns \(0: a\) have mixed types. "
262+ "Specify dtype option on import or set low_memory=False." ,
263+ buf ,
264+ )
260265 if parser .engine == "c" and parser .low_memory :
261266 assert df .a .dtype == object
262267 elif using_infer_string :
0 commit comments