Skip to content

Commit

Permalink
fix test to run on windows with windows line endings (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Aug 10, 2020
1 parent 93f7ac7 commit ebec5fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ jobs:
uses: actions/cache@v1
id: cache
with:
path: .cache/pip
path: |
.cache/pip
eggs
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt', 'constraints.txt', 'buildout.cfg', 'setup.*') }}
restore-keys: |
${{ runner.os }}-test
- name: Install dependencies
run: |
pip install -U pip
pip install --user -U pip
pip install -r requirements.txt -c constraints.txt
buildout
- name: Run Tests
Expand Down
15 changes: 12 additions & 3 deletions src/z3c/jbot/tests/test_doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,28 @@
from .common import setUp
from .common import tearDown

OPTIONFLAGS = (doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE)
OPTIONFLAGS = (
doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
)


class Py23DocChecker(doctest.OutputChecker):
def check_output(self, want, got, optionflags):
# fix windows line-endings to match ones in tests
got = got.replace(r"\r\n", r"\n")
# fix binary/unicode differences between python versions
if six.PY2:
want = re.sub("b'(.*?)'", "'\\1'", want)
else:
want = re.sub("u'(.*?)'", "'\\1'", want)
want = want.replace(r"\r\n", r"\n")
return doctest.OutputChecker.check_output(self, want, got, optionflags)

def output_difference(self, example, got, optionflags):
# fix windows line-endings to match ones in tests
got = got.replace(r"\r\n", r"\n")
return doctest.OutputChecker.output_difference(
self, example, got, optionflags)


def test_suite():
globs = dict(
Expand Down

0 comments on commit ebec5fd

Please sign in to comment.