Skip to content

Commit

Permalink
Sybil 2/3, Pytest 6/7 compatibility.
Browse files Browse the repository at this point in the history
Resolves #167
  • Loading branch information
cjw296 authored Feb 25, 2022
2 parents 2900388 + 0c1d79f commit df64fb3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ common: &common
- python/pip-run-tests:
name: python36
image: cimg/python:3.6
extra_packages: "'sybil<3' 'pytest<7'"
- python/pip-run-tests:
name: python39
image: cimg/python:3.9
Expand Down
14 changes: 11 additions & 3 deletions docs/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from doctest import REPORT_NDIFF, ELLIPSIS

from sybil import Sybil
from sybil.parsers.doctest import DocTestParser, FIX_BYTE_UNICODE_REPR
from sybil.parsers.codeblock import CodeBlockParser
from sybil.parsers.doctest import DocTestParser
try:
from sybil.parsers.doctest import FIX_BYTE_UNICODE_REPR
except ImportError:
# sybil 3 removed the optionflag
FIX_BYTE_UNICODE_REPR = 0
try:
from sybil.parsers.codeblock import PythonCodeBlockParser
except ImportError:
from sybil.parsers.codeblock import CodeBlockParser as PythonCodeBlockParser
from sybil.parsers.capture import parse_captures

from testfixtures.compat import PY3
Expand All @@ -13,7 +21,7 @@
pytest_collect_file = Sybil(
parsers=[
DocTestParser(optionflags=REPORT_NDIFF|ELLIPSIS|FIX_BYTE_UNICODE_REPR),
CodeBlockParser(['print_function']),
PythonCodeBlockParser(['print_function']),
parse_captures,
FileParser('tempdir'),
],
Expand Down
6 changes: 3 additions & 3 deletions docs/django.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Traceback (most recent call last):
AssertionError: SampleModel not as expected:
<BLANKLINE>
same:
[u'id']
['id']
<BLANKLINE>
values differ:
'value': 1 != 2
Expand All @@ -38,7 +38,7 @@ Traceback (most recent call last):
AssertionError: SampleModel not as expected:
<BLANKLINE>
same:
[u'id']
['id']
<BLANKLINE>
values differ:
'value': 1 != 2
Expand Down Expand Up @@ -70,7 +70,7 @@ Traceback (most recent call last):
AssertionError: SampleModel not as expected:
<BLANKLINE>
same:
['created', u'id', 'value']
['created', 'id', 'value']
<BLANKLINE>
values differ:
'not_editable': 1 != 2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'zope.component',
'django<2;python_version<"3"',
'django;python_version>="3"',
'sybil<3',
'sybil',
'twisted'
]

Expand Down
8 changes: 6 additions & 2 deletions testfixtures/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from sybil import Sybil
from sybil.parsers.doctest import DocTestParser
from sybil.parsers.codeblock import CodeBlockParser
try:
from sybil.parsers.codeblock import PythonCodeBlockParser
except ImportError:
# sybil < 3 has it under the old name
from sybil.parsers.codeblock import CodeBlockParser as PythonCodeBlockParser
from sybil.parsers.capture import parse_captures

from testfixtures import TempDirectory
Expand All @@ -18,7 +22,7 @@ def sybil_teardown(namespace):
pytest_collect_file = Sybil(
parsers=[
DocTestParser(),
CodeBlockParser(),
PythonCodeBlockParser(),
parse_captures,
FileParser('tempdir'),
],
Expand Down

0 comments on commit df64fb3

Please sign in to comment.