File: test_base.py

package info (click to toggle)
python-pyocr 0.8.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 548 kB
  • sloc: python: 4,921; makefile: 90; sh: 3
file content (26 lines) | stat: -rw-r--r-- 710 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
import os
import unittest


class BaseTest(unittest.TestCase):
    tool = None

    def setUp(self):
        self.file_descriptors = []

    def tearDown(self):
        for fd in self.file_descriptors:
            fd.close()

    def _get_file_handle(self, filename):
        fd = open(os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "data", filename
        ), encoding="utf-8")
        self.file_descriptors.append(fd)
        return fd

    def _get_file_content(self, filename):
        with open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               "data", filename), encoding="utf-8") as fh:
            content = fh.read()
        return content