mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Remaining Python 3 compatibility changes
Summary: Biggest change is turning everything to unicode Test Plan: The tests Reviewers: dsagal, paulfitz Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2875
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import doctest
|
||||
import os
|
||||
import re
|
||||
|
||||
import six
|
||||
|
||||
import functions
|
||||
import moment
|
||||
|
||||
@@ -15,6 +19,12 @@ def date_tearDown(doc_test):
|
||||
# pylint: disable=unused-argument
|
||||
functions.date._get_global_tz = _old_date_get_global_tz
|
||||
|
||||
class Py23DocChecker(doctest.OutputChecker):
|
||||
def check_output(self, want, got, optionflags):
|
||||
if six.PY3:
|
||||
want = re.sub(r"^u'(.*?)'$", r"'\1'", want)
|
||||
want = re.sub(r'^u"(.*?)"$', r'"\1"', want)
|
||||
return doctest.OutputChecker.check_output(self, want, got, optionflags)
|
||||
|
||||
# This works with the unittest module to turn all the doctests in the functions' doc-comments into
|
||||
# unittest test cases.
|
||||
@@ -26,8 +36,8 @@ def load_tests(loader, tests, ignore):
|
||||
tests.addTests(doctest.DocTestSuite(functions.logical))
|
||||
tests.addTests(doctest.DocTestSuite(functions.math))
|
||||
tests.addTests(doctest.DocTestSuite(functions.stats))
|
||||
tests.addTests(doctest.DocTestSuite(functions.text))
|
||||
tests.addTests(doctest.DocTestSuite(functions.text, checker=Py23DocChecker()))
|
||||
tests.addTests(doctest.DocTestSuite(functions.schedule,
|
||||
setUp = date_setUp, tearDown = date_tearDown))
|
||||
tests.addTests(doctest.DocTestSuite(functions.lookup))
|
||||
tests.addTests(doctest.DocTestSuite(functions.lookup, checker=Py23DocChecker()))
|
||||
return tests
|
||||
|
||||
Reference in New Issue
Block a user