summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYu-Jie Lin <livibetter@gmail.com>2013-08-20 10:27:29 +0800
committerYu-Jie Lin <livibetter@gmail.com>2013-08-20 10:27:29 +0800
commit5bb74b2af16a4834f27e53c1eec4dc9b5bddd745 (patch)
treea4a821add880df2771698faeb8ce718bb462abbc /tests
parentd7c010822addabf276b2a61ba18a35f1651db2d5 (diff)
downloadsmartypants-5bb74b2af16a4834f27e53c1eec4dc9b5bddd745.tar.gz
fix deprecated smartyPants() returns nothing, add test file for deprecated stuff. fix #2
Diffstat (limited to 'tests')
-rw-r--r--tests/test.py12
-rw-r--r--tests/test_deprecated.py40
2 files changed, 40 insertions, 12 deletions
diff --git a/tests/test.py b/tests/test.py
index d019f88..549b19f 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -94,18 +94,6 @@ document.write('<a href="' + href + '">' + linktext + "</a>");
self.assertEqual(sp('"Isn\'t this fun?"'),
'&#8220;Isn&#8217;t this fun?&#8221;')
- def test_deprecated_str_attr(self):
-
- TEXT = '"foo" -- bar'
-
- T = sp(TEXT, 'q')
- E = '&#8220;foo&#8221; -- bar'
- self.assertEquals(T, E)
-
- T = sp(TEXT, 'qd')
- E = '&#8220;foo&#8221; &#8212; bar'
- self.assertEquals(T, E)
-
def load_tests(loader, tests, pattern):
diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py
new file mode 100644
index 0000000..1990f1f
--- /dev/null
+++ b/tests/test_deprecated.py
@@ -0,0 +1,40 @@
+#!/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
+
+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 = '&#8220;foo&#8221; -- bar'
+ self.assertEquals(T, E)
+
+ T = sp(TEXT, 'qd')
+ E = '&#8220;foo&#8221; &#8212; 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 = '&#8220;foo&#8221; -- bar'
+ self.assertEquals(T, E)
+
+ self.assertEquals(len(w), 1)