summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2014-03-11 00:09:19 +0100
committerMartin Vilcans <martin@librador.com>2014-03-11 00:09:19 +0100
commit9c2e3683e207e81cf88350fde2dfadcecd5cc914 (patch)
treeb9ebee2cc9739f8c6ea02ee84a4d7e76e25d0f7b
parent436c6c702bedbce65936fb0d8eab09053015de61 (diff)
Patch doctests to work with Python 3python3
-rwxr-xr-xbin/test3
-rw-r--r--test.py24
2 files changed, 25 insertions, 2 deletions
diff --git a/bin/test b/bin/test
index dcefe4f..da49a7e 100755
--- a/bin/test
+++ b/bin/test
@@ -1,3 +1,2 @@
#!/bin/bash
-nosetests --nocapture --with-doctest --doctest-tests $* && \
- pep8 screenplain tests
+python test.py && pep8 screenplain tests
diff --git a/test.py b/test.py
new file mode 100644
index 0000000..c4e5887
--- /dev/null
+++ b/test.py
@@ -0,0 +1,24 @@
+"""Runs nosetest after preparing the test cases.
+
+Removes the leading u from unicode literals so
+Python 3 doctests won't fail.
+
+"""
+
+from screenplain import richstring
+import re
+
+unicode_literal = re.compile(r'u([\'"])')
+
+for n in (
+ 'parse_emphasis',
+ '_unescape',
+ '_demagic_literals',
+):
+ attr = getattr(richstring, n)
+ old_doc = getattr(attr, '__doc__')
+ new_doc = unicode_literal.sub(r'\1', old_doc)
+ setattr(attr, '__doc__', new_doc)
+
+import nose
+nose.main(argv='nosetests --nocapture --with-doctest --doctest-tests'.split())