~ubuntu-branches/ubuntu/wily/openpyxl/wily-proposed

« back to all changes in this revision

Viewing changes to openpyxl/tests/test_strings.py

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2011-11-18 15:56:52 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20111118155652-bsxf6i5wq4ptg2ln
Tags: 1.5.6-1
Fresh upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# file openpyxl/tests/test_strings.py
2
2
 
3
 
# Copyright (c) 2010 openpyxl
 
3
# Copyright (c) 2010-2011 openpyxl
4
4
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
21
21
# THE SOFTWARE.
22
22
#
23
23
# @license: http://www.opensource.org/licenses/mit-license.php
24
 
# @author: Eric Gazoni
 
24
# @author: see AUTHORS file
25
25
 
26
26
# Python stdlib imports
27
 
from __future__ import with_statement
28
27
import os.path
29
28
 
30
29
# 3rd party imports
48
47
 
49
48
 
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'))
 
51
    try:
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)
 
55
    finally:
 
56
        handle.close()
55
57
 
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'))
 
60
     try:
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)
 
64
     finally:
 
65
         handle.close()
61
66
 
62
67
def test_formatted_string_table():
63
 
    with open(os.path.join(DATADIR, 'reader', 'shared-strings-rich.xml')) \
64
 
            as handle:
 
68
    handle = open(os.path.join(DATADIR, 'reader', 'shared-strings-rich.xml'))
 
69
    try:
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)
 
74
    finally:
 
75
        handle.close()