-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escaping special symbols now working correct when dumping; typo on RE…
…ADME corrected; bad assertition removed on test_loads_dumps
- Loading branch information
Showing
5 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
import arff | ||
|
||
ARFF_SOURCE = '''% | ||
@RELATION teste | ||
@ATTRIBUTE a STRING | ||
@ATTRIBUTE b {a, b, c, d} | ||
@ATTRIBUTE c STRING | ||
@DATA | ||
lorem, b, thisisavalidstatement | ||
lorem, b, 'this is a valid statement with an % symbol' | ||
lorem2, d, 'this is a valid statement' | ||
lorem3, c, 'this is a valid statement with double quotes included """""""! ' | ||
lorem4, a, 'this is a valid statement with singlequotes included \' lol \'! ' | ||
''' | ||
|
||
ARFF_DESTINY = '''@RELATION teste | ||
@ATTRIBUTE a STRING | ||
@ATTRIBUTE b {a, b, c, d} | ||
@ATTRIBUTE c STRING | ||
@DATA | ||
lorem,b,thisisavalidstatement | ||
lorem,b,'this is a valid statement with an \\% symbol' | ||
lorem2,d,'this is a valid statement' | ||
lorem3,c,'this is a valid statement with double quotes included \\"\\"\\"\\"\\"\\"\\"! ' | ||
lorem4,a,'this is a valid statement with singlequotes included \\\' lol \\\'! ' | ||
% | ||
% | ||
% ''' | ||
|
||
|
||
class TestDumpEscape(unittest.TestCase): | ||
def test_encode_source(self): | ||
obj = arff.loads(ARFF_SOURCE) | ||
result = arff.dumps(obj) | ||
expected = ARFF_DESTINY | ||
|
||
self.assertEqual(result, expected) | ||
|
||
def test_encode_destiny(self): | ||
src = ARFF_DESTINY | ||
|
||
count = 0 | ||
while count < 10: | ||
count += 1 | ||
|
||
obj = arff.loads(src) | ||
src = arff.dumps(obj) | ||
self.assertEqual(src, ARFF_DESTINY) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,3 @@ def test_simple(self): | |
arff = dumps(obj) | ||
self.assertEqual(arff, ARFF) | ||
|
||
assert False |