示例#1
0
    def test_string_quotes(self):
        cell = Cell(address="A1", sheet="sheet1")
        cell.value = u"hello \"world'"

        code, ast = cell2code(cell, named_ranges=[])

        assert code == u'u"hello \\"world\'"'

        RangeCore
        assert eval(code) == u"hello \"world'"
示例#2
0
    def test_formula(self):
        cell = Cell(address="A1", sheet="sheet1")
        cell.formula = "10+20"

        code, ast = cell2code(cell, named_ranges=[])

        assert code == 'RangeCore.apply("add",10,20,(1, \'A\'))'

        RangeCore
        assert eval(code) == 30
示例#3
0
    def test_formula_string_unicode(self):
        cell = Cell(address="A1", sheet="sheet1")
        cell.formula = "=IF(1, \"a☺\", \"b☺\")"

        code, ast = cell2code(cell, named_ranges=[])

        assert code == u'("a☺" if 1 else "b☺")'

        RangeCore
        assert eval(code) == u"a☺"
示例#4
0
    def test_string_unicode(self):
        cell = Cell(address="A1", sheet="sheet1")
        cell.value = u"hello world ☺"

        code, ast = cell2code(cell, named_ranges=[])

        assert code == u'"hello world ☺"'

        RangeCore
        assert eval(code) == u"hello world ☺"
示例#5
0
    def test_formula(self):
        cell = Cell(address="A1", sheet="sheet1")
        cell.formula = "10+20"

        code, ast = cell2code(cell, named_ranges=[])

        assert code == 'RangeCore.apply("add",10,20,(1, \'A\'))'

        RangeCore
        assert eval(code) == 30
示例#6
0
    def test_string_quotes(self):
        cell = Cell(address="A1", sheet="sheet1")
        cell.value = u"hello \"world'"

        code, ast = cell2code(cell, named_ranges=[])

        assert code == u'u"hello \\"world\'"'

        RangeCore
        assert eval(code) == u"hello \"world'"
示例#7
0
    def test_formula_string_unicode(self):
        cell = Cell(address="A1", sheet="sheet1")
        cell.formula = "=IF(1, \"a☺\", \"b☺\")"

        code, ast = cell2code(cell, named_ranges=[])

        assert code == u'("a☺" if 1 else "b☺")'

        RangeCore
        assert eval(code) == u"a☺"