summaryrefslogtreecommitdiff
path: root/tests/test_deprecated.py
blob: 35c04d87ff1aab194bb33c7d7321788910ebc398 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# Copyright (c) 2013 Yu-Jie Lin
# Licensed under the BSD License, for detailed license information, see COPYING

import unittest
import warnings

import smartypants as sps
from smartypants import Attr, smartypants as sp, smartyPants as sP


class SmartyPantsDeprecatedTestCase(unittest.TestCase):

    def test_str_attr(self):

        TEXT = '"foo" -- bar'

        with warnings.catch_warnings(record=True) as w:

            T = sp(TEXT, 'q')
            E = '“foo” -- bar'
            self.assertEquals(T, E)

            T = sp(TEXT, 'qd')
            E = '“foo” — bar'
            self.assertEquals(T, E)

            # should only get warning 'once'
            self.assertEquals(len(w), 1)

    def test_smartyPants(self):

        TEXT = '"foo" -- bar'

        with warnings.catch_warnings(record=True) as w:

            T = sP(TEXT, Attr.q)
            E = '“foo” -- bar'
            self.assertEquals(T, E)

            self.assertEquals(len(w), 1)

    def test_educateQuotes(self):

        TEXT = '"foo" -- bar'

        with warnings.catch_warnings(record=True) as w:

            T = sps.educateQuotes(TEXT)
            E = '“foo” -- bar'
            self.assertEquals(T, E)

            self.assertEquals(len(w), 1)