From 9c2e3683e207e81cf88350fde2dfadcecd5cc914 Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Tue, 11 Mar 2014 00:09:19 +0100 Subject: Patch doctests to work with Python 3 --- test.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test.py (limited to 'test.py') 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()) -- cgit v1.2.3