File tree Expand file tree Collapse file tree 7 files changed +49
-5
lines changed Expand file tree Collapse file tree 7 files changed +49
-5
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
4
4
5
5
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/en/1.0.0/ ) and this project adheres to [ Semantic Versioning] ( http://semver.org/spec/v2.0.0.html ) .
6
6
7
+ ## [ 5.1.9] - 2024-02-06
8
+
9
+ ### Added
10
+
11
+ - Tests for encoding of messages in Sender.
12
+
13
+ ### Changed
14
+
15
+ - UFT-8 encoding with "replace" is now used by default in Sender.
16
+
7
17
## [ 5.1.8] - 2024-01-10
8
18
9
19
### Added
Original file line number Diff line number Diff line change 1
1
The MIT License (MIT)
2
2
3
- Copyright (C) 2023 Devo, Inc.
3
+ Copyright (C) 2024 Devo, Inc.
4
4
5
5
Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
of this software and associated documentation files (the "Software"), to deal
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ You can contact with us at _support@devo.com_.
203
203
204
204
MIT License
205
205
206
- (C) 2023 Devo, Inc.
206
+ (C) 2024 Devo, Inc.
207
207
208
208
Permission is hereby granted, free of charge, to any person obtaining a copy of
209
209
this software and associated documentation files (the 'Software'), to deal in
Original file line number Diff line number Diff line change 1
1
__description__ = "Devo Python Library."
2
2
__url__ = "http://www.devo.com"
3
- __version__ = "5.1.8 "
3
+ __version__ = "5.1.9 "
4
4
__author__ = "Devo"
5
5
__author_email__ = "support@devo.com"
6
6
__license__ = "MIT"
7
- __copyright__ = "Copyright 2023 Devo"
7
+ __copyright__ = "Copyright 2024 Devo"
Original file line number Diff line number Diff line change @@ -625,7 +625,7 @@ def __encode_record(record):
625
625
:return: record encoded for PY3
626
626
"""
627
627
if not isinstance (record , bytes ):
628
- return record .encode ("utf-8" )
628
+ return record .encode ("utf-8" , "replace" )
629
629
return record
630
630
631
631
def __send_oc (self , record ):
Original file line number Diff line number Diff line change 22
22
from tests .sender .test_number_lookup import TestLookup as SENDER_NUMBER_LOOKUP
23
23
from tests .sender .test_read_csv import TestCSVRFC as SENDER_CSV
24
24
from tests .sender .test_send_data import TestSender as SENDER_SEND_DATA
25
+ from tests .sender .test_send_encoding import TestEncoding as SENDER_SEND_ENCODING
25
26
from tests .sender .test_send_lookup import TestLookup as SENDER_SEND_LOOKUP
26
27
27
28
module_paths = {
38
39
"SENDER_CSV" : SENDER_CSV ,
39
40
"SENDER_NUMBER_LOOKUP" : SENDER_NUMBER_LOOKUP ,
40
41
"SENDER_SEND_DATA" : SENDER_SEND_DATA ,
42
+ "SENDER_SEND_ENCODING" : SENDER_SEND_ENCODING ,
41
43
"SENDER_SEND_LOOKUP" : SENDER_SEND_LOOKUP ,
42
44
}
43
45
Original file line number Diff line number Diff line change
1
+ import unittest
2
+ from devo .sender .data import Sender
3
+
4
+ # This test case uses the private method __encode_record to test the encoding
5
+ # of the records and needs some name mangling to access it.
6
+
7
+
8
+ class TestEncoding (unittest .TestCase ):
9
+
10
+ def test_encode_record_ascii (self ):
11
+ record = 'Hello' # ASCII Normal sequence
12
+ encoded_record = Sender ._Sender__encode_record (record )
13
+ self .assertEqual (encoded_record , b'Hello' )
14
+
15
+ def test_encode_record_utf8 (self ):
16
+ record = 'Hello 🌍, こんにちは' # UTF-8 sequence
17
+ encoded_record = Sender ._Sender__encode_record (record )
18
+ self .assertEqual (encoded_record , b'Hello \xf0 \x9f \x8c \x8d , \xe3 \x81 \x93 \xe3 \x82 \x93 \xe3 \x81 \xab \xe3 \x81 \xa1 \xe3 \x81 \xaf ' )
19
+
20
+ def test_encode_record_utf8_with_byte_sequence (self ):
21
+ record = '10 €' # UTF-8 valid byte sequence
22
+ encoded_record = Sender ._Sender__encode_record (record )
23
+ self .assertEqual (encoded_record , b'10 \xe2 \x82 \xac ' )
24
+
25
+ def test_encode_record_utf16_surrogate (self ):
26
+ record = '\uD83D Hello' # UTF-16 sequence
27
+ encoded_record = Sender ._Sender__encode_record (record )
28
+ self .assertEqual (encoded_record , b'? Hello' )
29
+
30
+
31
+ if __name__ == "__main__" :
32
+ unittest .main ()
You can’t perform that action at this time.
0 commit comments