File: test_memleak.py

package info (click to toggle)
python-html2text 2014.9.25-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 404 kB
  • ctags: 143
  • sloc: python: 1,073; sh: 76; makefile: 14
file content (32 lines) | stat: -rw-r--r-- 879 bytes parent folder | download | duplicates (2)
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
import sys
if sys.version_info[:2] < (2, 7):
    import unittest2 as unittest
else:
    import unittest
import logging
logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s',
                    level=logging.DEBUG)

import html2text


class TestMemleak(unittest.TestCase):
    """
    See https://github.com/Alir3z4/html2text/issues/13 for more
    information on this.
    """

    def setUp(self):
        self.instr = 'miow '

    def test_same_string(self):
        h2t = html2text.HTML2Text()
        result = h2t.handle(self.instr)
        # Now, we shouldn't get leak of the previous run to the new one
        self.assertEqual(h2t.handle(self.instr), result)

    def test_empty_string(self):
        h2t = html2text.HTML2Text()
        h2t.handle(self.instr)
        # And even less when the input is empty
        self.assertEqual(h2t.handle(''), '\n\n')