(unicode_string, encoding)
| 7 | |
| 8 | |
| 9 | def check_reader(unicode_string, encoding): |
| 10 | bytestr = unicode_string.encode(encoding) |
| 11 | stream = BytesIO(bytestr) |
| 12 | reader = SeekableUnicodeStreamReader(stream, encoding) |
| 13 | |
| 14 | # Should open at the start of the file |
| 15 | assert reader.tell() == 0 |
| 16 | |
| 17 | # Compare original string to contents from `.readlines()` |
| 18 | assert unicode_string == "".join(reader.readlines()) |
| 19 | |
| 20 | # Should be at the end of the file now |
| 21 | stream.seek(0, os.SEEK_END) |
| 22 | assert reader.tell() == stream.tell() |
| 23 | |
| 24 | reader.seek(0) # go back to start |
| 25 | |
| 26 | # Compare original string to contents from `.read()` |
| 27 | contents = "" |
| 28 | char = None |
| 29 | while char != "": |
| 30 | char = reader.read(1) |
| 31 | contents += char |
| 32 | assert unicode_string == contents |
| 33 | |
| 34 | |
| 35 | # Call `check_reader` with a variety of input strings and encodings. |
no test coverage detected
searching dependent graphs…