Skip to content
This repository was archived by the owner on May 4, 2020. It is now read-only.

Start of a test suite #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added tests/__init__.py
Empty file.
Binary file added tests/python.bmp
Binary file not shown.
35 changes: 35 additions & 0 deletions tests/test_biffrecords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
__author__ = 'hrwl'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No author lines please.


import unittest
import six
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reliance on six please. We didn't need it for xlrd and I'm keep to keep it the same for xlwt. We just want our own 'compat' module in xlwt/compat.py...


from xlwt import BIFFRecords


class SharedStringTableTestCase(unittest.TestCase):
def test_shared_string_table(self):
expected_result = six.b('\xfc\x00\x11\x00\x01\x00\x00\x00\x01\x00\x00\x00\x03\x00\x01\x1e\x04;\x04O\x04')
string_record = BIFFRecords.SharedStringTable(encoding='cp1251')
string_record.add_str(six.b('\xCE\xEB\xFF'))
self.assertEqual(expected_result, string_record.get_biff_record())

expected_result = six.b('\xfc\x00\x16\x00\x01\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00All around!')
string_record = BIFFRecords.SharedStringTable(encoding='ascii')
string_record.add_str(six.b('All around!'))
self.assertEqual(expected_result, string_record.get_biff_record())


class Biff8BOFRecordTestCase(unittest.TestCase):
def test_class(self):
biff = BIFFRecords.Biff8BOFRecord(BIFFRecords.Biff8BOFRecord.BOOK_GLOBAL).get()
self.assertEqual(six.b('\x09\x08\x10\x00\x00\x06\x05\x00\xbb\x0D\xcc\x07\x00\x00\x00\x00\x06\x00\x00\x00'), biff)


class WriteAccessRecordTestCase(unittest.TestCase):
def test_class(self):
biff = BIFFRecords.WriteAccessRecord('Hans').get()
self.assertEqual(six.b('\\\x00p\x00Hans '), biff)

if __name__ == '__main__':
unittest.main()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll use nose, so don't need this boilerplate. Please can you remove it?


Loading