File: test_open_workbook.py

package info (click to toggle)
python-xlrd 2.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,832 kB
  • sloc: python: 7,531; makefile: 118; sh: 7
file content (36 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import shutil
import tempfile
from unittest import TestCase

import pytest

from xlrd import open_workbook, XLRDError

from .helpers import from_sample


class TestOpen(object):
    # test different uses of open_workbook

    def test_names_demo(self):
        # For now, we just check this doesn't raise an error.
        open_workbook(from_sample('namesdemo.xls'))

    def test_ragged_rows_tidied_with_formatting(self):
        # For now, we just check this doesn't raise an error.
        open_workbook(from_sample('issue20.xls'),
                      formatting_info=True)

    def test_BYTES_X00(self):
        # For now, we just check this doesn't raise an error.
        open_workbook(from_sample('picture_in_cell.xls'),
                      formatting_info=True)

    def test_open_xlsx(self):
        with pytest.raises(XLRDError, match='Excel xlsx file; not supported'):
            open_workbook(from_sample('sample.xlsx'))

    def test_open_unknown(self):
        with pytest.raises(XLRDError, match="Unsupported format, or corrupt file"):
            open_workbook(from_sample('sample.txt'))