Patchwork [1,of,4] tests: allow running doctests selectively on Python 3

login
register
mail settings
Submitter Yuya Nishihara
Date March 16, 2017, 3:31 p.m.
Message ID <f39291c08d86082579b8.1489678270@mimosa>
Download mbox | patch
Permalink /patch/19392/
State Accepted
Headers show

Comments

Yuya Nishihara - March 16, 2017, 3:31 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1488978812 -32400
#      Wed Mar 08 22:13:32 2017 +0900
# Node ID f39291c08d86082579b891e844cbd56752b44a59
# Parent  63a39d64788872a5742f8e3143b7ddd603e3af13
tests: allow running doctests selectively on Python 3

Currently most doctests fail on Python 3, but I want to add some.

Patch

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -5,10 +5,16 @@  from __future__ import absolute_import
 import doctest
 import os
 import sys
+
+ispy3 = (sys.version_info[0] >= 3)
+
 if 'TERM' in os.environ:
     del os.environ['TERM']
 
-def testmod(name, optionflags=0, testtarget=None):
+# TODO: migrate doctests to py3 and enable them on both versions
+def testmod(name, optionflags=0, testtarget=None, py2=True, py3=False):
+    if not (not ispy3 and py2 or ispy3 and py3):
+        return
     __import__(name)
     mod = sys.modules[name]
     if testtarget is not None: