File: test_hyperlinks.py

package info (click to toggle)
striprtf 0.0.29-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,488 kB
  • sloc: python: 707; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,225 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
37
38
39
import unittest
from pathlib import Path

from striprtf.striprtf import rtf_to_text

RTF_DIR = Path.cwd() / "tests" / "rtf"
TEXT_DIR = Path.cwd() / "tests" / "text"


class TestHyperlinks(unittest.TestCase):
    def test_hyperlinks(self):
        example_rtf = RTF_DIR / "hyperlinks.rtf"
        example_txt = TEXT_DIR / "hyperlinks.txt"

        with example_rtf.open() as source:
            result = rtf_to_text(source.read())

        with example_txt.open() as destination:
            self.assertEqual(destination.read(), result)

    def test_mac_textedit(self):
        example_rtf = RTF_DIR / "mac_textedit_hyperlink.rtf"
        example_txt = TEXT_DIR / "mac_textedit_hyperlink.txt"

        with example_rtf.open() as source:
            result = rtf_to_text(source.read())

        with example_txt.open() as destination:
            self.assertEqual(destination.read(), result)

    def test_user_sample(self):
        example_rtf = RTF_DIR / "Example_text.rtf"
        example_txt = TEXT_DIR / "Example_text.txt"

        with example_rtf.open() as source:
            result = rtf_to_text(source.read())

        with example_txt.open() as destination:
            self.assertEqual(destination.read(), result)