1
1
# file openpyxl/tests/test_strings.py
3
# Copyright (c) 2010 openpyxl
3
# Copyright (c) 2010-2011 openpyxl
5
5
# Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
# of this software and associated documentation files (the "Software"), to deal
50
49
def test_read_string_table():
51
with open(os.path.join(DATADIR, 'reader', 'sharedStrings.xml')) as handle:
50
handle = open(os.path.join(DATADIR, 'reader', 'sharedStrings.xml'))
52
52
content = handle.read()
53
string_table = read_string_table(content)
54
eq_({0: 'This is cell A1 in Sheet 1', 1: 'This is cell G5'}, string_table)
53
string_table = read_string_table(content)
54
eq_({0: 'This is cell A1 in Sheet 1', 1: 'This is cell G5'}, string_table)
56
58
def test_empty_string():
57
with open(os.path.join(DATADIR, 'reader', 'sharedStrings-emptystring.xml')) as handle:
59
handle = open(os.path.join(DATADIR, 'reader', 'sharedStrings-emptystring.xml'))
58
61
content = handle.read()
59
string_table = read_string_table(content)
60
eq_({0: 'Testing empty cell', 1:''}, string_table)
62
string_table = read_string_table(content)
63
eq_({0: 'Testing empty cell', 1:''}, string_table)
62
67
def test_formatted_string_table():
63
with open(os.path.join(DATADIR, 'reader', 'shared-strings-rich.xml')) \
68
handle = open(os.path.join(DATADIR, 'reader', 'shared-strings-rich.xml'))
65
70
content = handle.read()
66
string_table = read_string_table(content)
67
eq_({0: 'Welcome', 1: 'to the best shop in town',
68
2: " let's play "}, string_table)
71
string_table = read_string_table(content)
72
eq_({0: 'Welcome', 1: 'to the best shop in town',
73
2: " let's play "}, string_table)