Skip to content

Commit

Permalink
Debugging: use logging rather than print
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Jul 23, 2018
1 parent c3b76ee commit d41ede5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions pandas/io/formats/csvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit d41ede5

Please sign in to comment.