示例#1
0
文件: test.py 项目: egils/OS
    def test_cell(self):

        cell2B = Cell(2)
        assert cell2B.value == '00'
        assert str(cell2B) == '00'

        cell2B.value = 0
        assert cell2B.value == ' 0'
        cell2B.value = 13
        assert cell2B.value == '13'
        cell2B.value = 'ab'
        assert cell2B.value == 'ab'
        cell2B.value = 'b'
        assert cell2B.value == ' b'
        cell2B.value = u'š'
        assert cell2B.value == '\xc5\xa1'
        try:
            cell2B.value = 123
        except exceptions.ValueError, e:
            assert unicode(e) == u'Reikšmė netelpa ląstelėje.'
示例#2
0
文件: test.py 项目: egils/OS
        assert cell2B.value == 'ab'
        cell2B.value = 'b'
        assert cell2B.value == ' b'
        cell2B.value = u'š'
        assert cell2B.value == '\xc5\xa1'
        try:
            cell2B.value = 123
        except exceptions.ValueError, e:
            assert unicode(e) == u'Reikšmė netelpa ląstelėje.'
        else:
            self.fail(u'Turėjo būti išmesta išimtis.'.encode('utf-8'))

        a = []
        def handler():
            a.append('called')
        cell2B = Cell(2, handler=handler)
        assert len(a) == 0
        cell2B.value = 2
        assert len(a) == 1
        assert a[0] == 'called'

    def test_register(self):

        class A(object):
            reg2B = Register(2)

        a = A()
        assert a.reg2B == '00'
        assert str(a.reg2B) == '00'

        a.reg2B = 0