From b9c5e36efa8e15757bb5d8f60a9d2c1c9e576c56 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sun, 23 Jul 2017 12:31:37 -0400 Subject: [PATCH] TST: remove some test warnings in parser tests TST: move highmemory test to proper location in c_parser_only xref #16798 --- pandas/conftest.py | 4 ++-- pandas/tests/io/parser/c_parser_only.py | 26 +++++++++++++++++++------ pandas/tests/io/parser/test_parsers.py | 16 --------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index bae45743bbcfb..101af46a63db4 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -10,7 +10,7 @@ def pytest_addoption(parser): help="skip slow tests") parser.addoption("--skip-network", action="store_true", help="skip network tests") - parser.addoption("--run-highmemory", action="store_true", + parser.addoption("--run-high-memory", action="store_true", help="run high memory tests") parser.addoption("--only-slow", action="store_true", help="run only slow tests") @@ -27,7 +27,7 @@ def pytest_runtest_setup(item): pytest.skip("skipping due to --skip-network") if 'high_memory' in item.keywords and not item.config.getoption( - "--run-highmemory"): + "--run-high-memory"): pytest.skip( "skipping high memory test since --run-highmemory was not set") diff --git a/pandas/tests/io/parser/c_parser_only.py b/pandas/tests/io/parser/c_parser_only.py index 48812c04e3b55..c68b2bf064d97 100644 --- a/pandas/tests/io/parser/c_parser_only.py +++ b/pandas/tests/io/parser/c_parser_only.py @@ -476,9 +476,23 @@ def test_read_tarfile(self, tar_suffix): # iterating through a file-like). tar_path = os.path.join(self.dirpath, "tar_csv" + tar_suffix) - tar = tarfile.open(tar_path, "r") - data_file = tar.extractfile("tar_data.csv") - - out = self.read_csv(data_file) - expected = pd.DataFrame({"a": [1]}) - tm.assert_frame_equal(out, expected) + with tarfile.open(tar_path, "r") as tar: + data_file = tar.extractfile("tar_data.csv") + + out = self.read_csv(data_file) + expected = pd.DataFrame({"a": [1]}) + tm.assert_frame_equal(out, expected) + + @pytest.mark.high_memory + def test_bytes_exceed_2gb(self): + """Read from a "CSV" that has a column larger than 2GB. + + GH 16798 + """ + if self.low_memory: + pytest.skip("not a high_memory test") + + csv = StringIO('strings\n' + '\n'.join( + ['x' * (1 << 20) for _ in range(2100)])) + df = self.read_csv(csv, low_memory=False) + assert not df.empty diff --git a/pandas/tests/io/parser/test_parsers.py b/pandas/tests/io/parser/test_parsers.py index f23bd24f5cbe3..9bbc624dff90f 100644 --- a/pandas/tests/io/parser/test_parsers.py +++ b/pandas/tests/io/parser/test_parsers.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- import os -from io import StringIO - -import pytest - import pandas.util.testing as tm from pandas import read_csv, read_table @@ -28,18 +24,6 @@ from .dtypes import DtypeTests -@pytest.mark.high_memory -def test_bytes_exceed_2gb(): - """Read from a "CSV" that has a column larger than 2GB. - - GH 16798 - """ - csv = StringIO('strings\n' + '\n'.join( - ['x' * (1 << 20) for _ in range(2100)])) - df = read_csv(csv, low_memory=False) - assert not df.empty - - class BaseParser(CommentTests, CompressionTests, ConverterTests, DialectTests, HeaderTests, IndexColTests,