File: doctest_custom.py

package info (click to toggle)
python-odoorpc 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 560 kB
  • sloc: python: 2,894; makefile: 154; sh: 4
file content (29 lines) | stat: -rw-r--r-- 788 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-

import sys
import re
from doctest import OutputChecker

from sphinx.ext.doctest import *


class Py23OutputChecker(OutputChecker):
    """OutputChecker to ignore unicode literals when checking outputs."""
    def check_output(self, want, got, optionflags):
        if got:
            got = re.sub("u'(.*?)'", "'\\1'", got)
            got = re.sub('u"(.*?)"', '"\\1"', got)
        return OutputChecker.check_output(self, want, got, optionflags)


original_init = SphinxDocTestRunner.__init__


def custom_init(self, checker=None, verbose=None, optionflags=0):
    checker = Py23OutputChecker()
    original_init(self, checker, verbose, optionflags)


SphinxDocTestRunner.__init__ = custom_init

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: