diff options
| author | Yu-Jie Lin <livibetter@gmail.com> | 2013-08-12 00:14:24 +0800 |
|---|---|---|
| committer | Yu-Jie Lin <livibetter@gmail.com> | 2013-08-12 00:14:24 +0800 |
| commit | c580044c0771b7fe55a15666cf6e8322ef042a29 (patch) | |
| tree | f500126dad02b0c453d073816a7f8a44b9109b99 /tests | |
| parent | 1e1c267aa36619749a82cfbd62a4f7fa69e44cb1 (diff) | |
| download | smartypants-git-c580044c0771b7fe55a15666cf6e8322ef042a29.tar.gz | |
fix PEP8, remove unused codes, separate README and unittest
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..5edc603 --- /dev/null +++ b/tests/test.py @@ -0,0 +1,53 @@ +import unittest + +from smartypants import smartyPants as sp + + +class TestSmartypantsAllAttributes(unittest.TestCase): + # the default attribute is "1", which means "all". + + def test_dates(self): + + self.assertEqual(sp("1440-80's"), "1440-80’s") + self.assertEqual(sp("1440-'80s"), "1440-‘80s") + self.assertEqual(sp("1440---'80s"), "1440–‘80s") + self.assertEqual(sp("1960s"), "1960s") # no effect. + self.assertEqual(sp("1960's"), "1960’s") + self.assertEqual(sp("one two '60s"), "one two ‘60s") + self.assertEqual(sp("'60s"), "‘60s") + + def test_skip_tags(self): + + T = sp('''<script type="text/javascript"> +<!-- +var href = "http://www.google.com"; +var linktext = "google"; +document.write('<a href="' + href + '">' + linktext + "</a>"); +//--> +</script>''') + E = '''<script type="text/javascript"> +<!-- +var href = "http://www.google.com"; +var linktext = "google"; +document.write('<a href="' + href + '">' + linktext + "</a>"); +//--> +</script>''' + self.assertEqual(T, E) + + T = sp("<p>He said "Let's write some code." This code here " + "<code>if True:\n\tprint "Okay"</code> is " + "python code.</p>") + E = ("<p>He said “Let’s write some code.” " + "This code here <code>if True:\n\tprint "Okay"</code> " + "is python code.</p>") + self.assertEqual(T, E) + + def test_ordinal_numbers(self): + + self.assertEqual(sp("21st century"), "21st century") # no effect. + self.assertEqual(sp("3rd"), "3rd") # no effect. + + def test_educated_quotes(self): + + self.assertEqual(sp('"Isn\'t this fun?"'), + '“Isn’t this fun?”') |
