Ticket #14359: trac_14359_doctest_unicode_warning.patch

File trac_14359_doctest_unicode_warning.patch, 3.6 KB (added by jdemeyer, 9 years ago)

Initial patch

  • doc/en/developer/conventions.rst

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1364315051 -3600
    # Node ID 38c7f802428600282c0a0d4c107c636067fd975b
    # Parent  6a64d0b3be2791eb40f73416c4a7f9f0350a0fdd
    Fix spurious unicode warning during doctests
    
    diff --git a/doc/en/developer/conventions.rst b/doc/en/developer/conventions.rst
    a b  
    420420          Improve further function ``have_fresh_beers`` using algorithm
    421421          ``buy_a_better_fridge``::
    422422
    423               sage: have_fresh_beers('Bière de l'Yvette') # todo: not implemented
     423              sage: have_fresh_beers('Bière de l\'Yvette') # todo: not implemented
    424424              Enjoy !
    425425
    426426- A REFERENCES block to list books or papers (optional). This block serves
  • sage/doctest/parsing.py

    diff --git a/sage/doctest/parsing.py b/sage/doctest/parsing.py
    a b  
     1## -*- encoding: utf-8 -*-
    12"""
    23This module contains functions and classes that parse docstrings.
    34
     
    2122import re, sys
    2223import doctest
    2324import collections
    24 from sage.misc.preparser import preparse
    25 from Cython.Build.Dependencies import strip_string_literals
     25from sage.misc.preparser import preparse, strip_string_literals
    2626
    2727float_regex = re.compile('([+-]?((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?)')
    2828optional_regex = re.compile(r'(long time|not implemented|not tested|known bug)|([^ a-z]\s*optional\s*[:-]*((\s|\w)*))')
     
    7171        set([])
    7272        sage: parse_optional_tags("    sage: print '  # long time'  # not tested")
    7373        set(['not tested'])
     74
     75    UTF-8 works::
     76
     77         sage: parse_optional_tags("'ěščřžýáíéďĎ'")
     78         set([])
    7479    """
    75     safe, literals = strip_string_literals(string)
     80    safe, literals, state = strip_string_literals(string)
    7681    first_line = safe.split('\n', 1)[0]
    7782    if '#' not in first_line:
    7883        return set()
    7984    comment = first_line[first_line.find('#')+1:]
     85    comment = comment[comment.index('(')+1 : comment.rindex(')')]
    8086    # strip_string_literals replaces comments
    8187    comment = "#" + (literals[comment]).lower()
    8288
     
    120126        sage: marked.abs_tol
    121127        0.01
    122128    """
    123     safe, literals = strip_string_literals(source)
     129    safe, literals, state = strip_string_literals(source)
    124130    first_line = safe.split('\n', 1)[0]
    125131    if '#' not in first_line:
    126132        return want
    127133    comment = first_line[first_line.find('#')+1:]
     134    comment = comment[comment.index('(')+1 : comment.rindex(')')]
    128135    # strip_string_literals replaces comments
    129136    comment = literals[comment]
    130137    if random_marker.search(comment):
  • sage/doctest/sources.py

    diff --git a/sage/doctest/sources.py b/sage/doctest/sources.py
    a b  
    677677            There are 1 tests in sage/ext/c_lib.pyx that are not being run
    678678            There are 9 tests in sage/graphs/graph_plot.py that are not being run
    679679            There are 2 tests in sage/server/notebook/worksheet.py that are not being run
    680             doctest:229: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
    681680            sage: os.chdir(cwd)
    682681        """
    683682        expected = []
  • sage/misc/messaging.py

    diff --git a/sage/misc/messaging.py b/sage/misc/messaging.py
    a b  
    6262    To set default values populate ``pushover_defaults``::
    6363
    6464        sage: sage.misc.messaging.pushover_defaults["user"] = "USER_TOKEN"
    65         sage: sage.misc.messaging.pushover("Hi, how are you?"") # not tested
     65        sage: sage.misc.messaging.pushover("Hi, how are you?") # not tested
    6666
    6767    .. note::
    6868