Ticket #11615: trac_11615-scripts-repo.patch

File trac_11615-scripts-repo.patch, 1.9 KB (added by jhpalmieri, 9 years ago)

scripts repo

  • sage-doctest

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1311187299 25200
    # Node ID 2d5d0b62da7539788907f18bc2d2864671ae8857
    # Parent  27d4cdeab60d90451e1eecb154560ad77539eaa3
    #11615: scripts repo: ignore 'requires' and 'needs' in optional doctesting
    implement 'known bug' better.
    
    diff --git a/sage-doctest b/sage-doctest
    a b def comment_modifier(s): 
    226226    eind = s.find('###',sind+1)
    227227    L = s[sind+1:eind].lower()
    228228    v = []
    229     if ('optional' in L) or ('known bug' in L):
     229    if 'optional' in L:
    230230        v.append(OPTIONAL)
     231    if 'known bug' in L:
     232        # Doctests marked like this should be automatically converted
     233        # to "optional bug", so they will be run by
     234        #
     235        #    sage -t ... --only-optional=bug
     236        #
     237        # So replace 'known' with '' or 'optional', depending on
     238        # whether 'optional' is already there.
     239        if 'optional' in L:
     240            L = L.replace('known', '')
     241        else:
     242            v.append(OPTIONAL)
     243            L = L.replace('known', 'optional')
    231244    if 'long time' in L:
    232245        v.append(LONG_TIME)
    233246    if 'not implemented' in L:
    def only_optional_include(s): 
    400413    if i == -1:
    401414        return False
    402415    if len(only_optional_tags) == 0:
    403         # this doctest has # optional in it, but there are no tags, which
     416        # This doctest has # optional in it, but there are no tags, which
    404417        # mean test everything that is optional.
    405418        return True
    406     # delete all white spaces and -'s
    407     s = ''.join(s[i+len('optional')+1:].replace('-','').split())
     419    # Delete all white space, colons, periods, commas, and hyphens:
     420    s = ','.join(s[i+len('optional')+1:].translate(None, '-:,.').split())
    408421    v = set(s.split(','))
     422    # Delete 'needs' and 'requires'.
     423    v.discard('needs')
     424    v.discard('requires')
    409425    return (len(v) > 0 and v.issubset(only_optional_tags))
    410426
    411427