Skip to content

Commit

Permalink
Convert CRLF to LF in cqlsh_print on Windows.
Browse files Browse the repository at this point in the history
Python converts to operating-system specific line-endings on any stream
write or print call which causes failures when coupled with doctest's
<BLANKLINE> replacement logic.
  • Loading branch information
Josh McKenzie committed Jun 4, 2015
1 parent 211d641 commit 087a3d2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions json_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import doctest
import inspect
import os
import re
import subprocess
import sys
from distutils.version import LooseVersion
from ccmlib import common
from ccmlib.common import is_win
from dtest import Tester
from tools import since

Expand Down Expand Up @@ -94,6 +96,13 @@ def cqlsh_print(cmds, supress_err=False):
"""
output = cqlsh(cmds, supress_err=supress_err)

# python coerces LF to OS-specific line-endings on print or write calls
# unless the stream is opened in binary mode. It's cleaner just to
# patch that up here so subsequent doctest comparisons to <BLANKLINE>
# pass, as they'll fail on Windows w/whitespace + ^M (CRLF)
if is_win():
output = re.sub(os.linesep, '\n', output)

if output:
print(output)

Expand Down

0 comments on commit 087a3d2

Please sign in to comment.