From d41ede5aed41864b478d000de3e452f63d8d2f98 Mon Sep 17 00:00:00 2001 From: Daniel Himmelstein Date: Mon, 23 Jul 2018 17:08:10 -0400 Subject: [PATCH] Debugging: use logging rather than print --- pandas/io/formats/csvs.py | 8 +++++--- pandas/tests/test_common.py | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pandas/io/formats/csvs.py b/pandas/io/formats/csvs.py index e4228c572dd5dd..9bebac3ebd1e30 100644 --- a/pandas/io/formats/csvs.py +++ b/pandas/io/formats/csvs.py @@ -134,10 +134,12 @@ def save(self): encoding = self.encoding # GH 21227 internal compression is not used when file-like passed. - print('debug_3', self.compression) - print('debug_4', self.path_or_buf) - print('debug_5', hasattr(self.path_or_buf, 'write')) + import logging + logging.warning('debug_3: {}'.format(self.compression)) + logging.warning('debug_4: {}'.format(self.path_or_buf)) + logging.warning('debug_5: {}'.format(hasattr(self.path_or_buf, 'write'))) if self.compression and hasattr(self.path_or_buf, 'write'): + logging.warning('debug_6: in loop, should RuntimeWarn') msg = ("compression has no effect when passing file-like " "object as input.") warnings.warn(msg, RuntimeWarning, stacklevel=2) diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index 238b780bb584d1..1177243df174ce 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -257,10 +257,11 @@ def test_compression_warning(compression_only): [12.32112, 123123.2, 321321.2]], columns=['X', 'Y', 'Z']) with tm.ensure_clean() as filename: - print('debug_1', compression_only) + import logging + logging.warning('debug_1: {}'.format(compression_only)) f, _handles = _get_handle(filename, 'w', compression=compression_only) with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False): with f: - print('debug_2', compression_only) + logging.warning('debug_2: {}'.format(compression_only)) df.to_csv(f, compression=compression_only)