Permalink
Browse files

Accept Unix newlines (\n) as separators for segments in loose mode.

  • Loading branch information...
1 parent 3ce17e2 commit 25e4110830ebfa8cdd8b2ea924664c9e96492f12 @johnpaulett committed Jan 17, 2012
Showing with 10 additions and 2 deletions.
  1. +2 −2 hl7/client.py
  2. +8 −0 tests/test_client.py
View
@@ -103,8 +103,8 @@ def read_loose(stream):
# load all the data (should only be 1 message)
data = stream.read()
- # Windows new lines to segment separators
- data = data.replace('\r\n', '\r')
+ # Windows & Unix new lines to segment separators
+ data = data.replace('\r\n', '\r').replace('\n', '\r')
# take out all the the typical MLLP separators and trailing
# whitespace
View
@@ -183,6 +183,14 @@ def test_loose_windows_newline(self):
self.mock_socket().send.assert_called_once_with(SB + 'foo\rbar' + EB + CR)
+ def test_loose_unix_newline(self):
+ self.option_values.loose = True
+ self.write(SB + 'foo\nbar\n' + EB + CR)
+
+ mllp_send()
+
+ self.mock_socket().send.assert_called_once_with(SB + 'foo\rbar' + EB + CR)
+
def test_loose_no_mllp_characters(self):
self.option_values.loose = True
self.write('foo\r\nbar\r\n')

0 comments on commit 25e4110

Please sign in to comment.