Skip to content

Commit

Permalink
Fix CI for Python 3.13 on Windows
Browse files Browse the repository at this point in the history
- Why the difference in behavior on the different platforms.
  • Loading branch information
metatoaster committed Oct 17, 2024
1 parent dc4a9c8 commit 78d5d21
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/calmjs/parse/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import doctest
from textwrap import dedent
from io import StringIO
from os.path import basename
from os.path import dirname
from pkg_resources import get_distribution

Expand All @@ -31,14 +32,27 @@
}


class StringIOWrapper(StringIO):
"""
Needed to rstrip the output to make all doctest output behave in a
consistent way across all platforms because for whatever reason the
doctest has different behaviors between Windows and others...
"""

def read(self):
return StringIO.read(self).rstrip()


def make_suite(): # pragma: no cover
from calmjs.parse.lexers import es5 as es5lexer
from calmjs.parse import walkers
from calmjs.parse import sourcemap

def open(p, flag='r'):
result = StringIO(examples[p] if flag == 'r' else '')
result.name = p
result = StringIOWrapper(examples[p] if flag == 'r' else '')
# Need basename here because Python 3.13 under Windows broke
# _something_ and made the reporting inconsistent...
result.name = basename(p)
return result

parser = doctest.DocTestParser()
Expand Down

0 comments on commit 78d5d21

Please sign in to comment.