@@ -177,34 +177,22 @@ def test_chunks_have_consistent_numerical_type(all_parsers):
177177def test_warn_if_chunks_have_mismatched_type (all_parsers , request ):
178178 warning_type = None
179179 parser = all_parsers
180- integers = [str (i ) for i in range (499999 )]
181- data = "a\n " + "\n " .join (integers + ["a" , "b" ] + integers )
180+ size = 10000
182181
183182 # see gh-3866: if chunks are different types and can't
184183 # be coerced using numerical types, then issue warning.
185184 if parser .engine == "c" and parser .low_memory :
186185 warning_type = DtypeWarning
186+ # Use larger size to hit warning path
187+ size = 499999
188+
189+ integers = [str (i ) for i in range (size )]
190+ data = "a\n " + "\n " .join (integers + ["a" , "b" ] + integers )
187191
188192 buf = StringIO (data )
189193
190- try :
191- with tm .assert_produces_warning (warning_type ):
192- df = parser .read_csv (buf )
193- except AssertionError as err :
194- # 2021-02-21 this occasionally fails on the CI with an unexpected
195- # ResourceWarning that we have been unable to track down,
196- # see GH#38630
197- if "ResourceWarning" not in str (err ) or parser .engine != "python" :
198- raise
199-
200- # Check the main assertion of the test before re-raising
201- assert df .a .dtype == object
202-
203- mark = pytest .mark .xfail (
204- reason = "ResourceWarning for unclosed SSL Socket, GH#38630"
205- )
206- request .node .add_marker (mark )
207- raise
194+ with tm .assert_produces_warning (warning_type ):
195+ df = parser .read_csv (buf )
208196
209197 assert df .a .dtype == object
210198
0 commit comments