aboutsummaryrefslogtreecommitdiffstats
path: root/community/py3-sybil/fix-tests-for-python-3-10.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/py3-sybil/fix-tests-for-python-3-10.patch')
-rw-r--r--community/py3-sybil/fix-tests-for-python-3-10.patch149
1 files changed, 0 insertions, 149 deletions
diff --git a/community/py3-sybil/fix-tests-for-python-3-10.patch b/community/py3-sybil/fix-tests-for-python-3-10.patch
deleted file mode 100644
index b261140173..0000000000
--- a/community/py3-sybil/fix-tests-for-python-3-10.patch
+++ /dev/null
@@ -1,149 +0,0 @@
-From 3650f5e609a6da7e114224a578e4182e262cdec5 Mon Sep 17 00:00:00 2001
-From: Chris Withers <chris@simplistix.co.uk>
-Date: Tue, 5 Oct 2021 08:29:21 +0100
-Subject: [PATCH] More specific pattern matching to help with Python 3.10
-
----
- tests/test_functional.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/tests/test_functional.py b/tests/test_functional.py
-index 6e77053..5bebfdb 100644
---- a/tests/test_functional.py
-+++ b/tests/test_functional.py
-@@ -15,7 +15,7 @@ def __init__(self, text):
- self.index = 0
-
- def then_find(self, substring):
-- assert substring in self.text[self.index:]
-+ assert substring in self.text[self.index:], self.text[self.index:]
- self.index = self.text.index(substring, self.index)
-
-
-@@ -99,14 +99,14 @@ def pytest_sessionfinish(self, session):
- 'sybil teardown 4\n'
- 'session_fixture teardown')
- out.then_find('_ fail.rst line=1 column=1 _')
-- out.then_find( "> raise Exception('the start!')")
-+ out.then_find("raise Exception('the start!')")
- out.then_find('_ fail.rst line=8 column=1 _')
- out.then_find('Y count was 3 instead of 2')
- out.then_find('fail.rst:8: SybilFailure')
- out.then_find('_ fail.rst line=10 column=1 _')
- out.then_find('ValueError: X count was 3 instead of 4')
- out.then_find('_ fail.rst line=14 column=1 _')
-- out.then_find("> raise Exception('boom!')")
-+ out.then_find("raise Exception('boom!')")
- out.then_find('fail.rst:18: Exception')
-
-
-From 4c12bfc0340a77cbe6496ebcef2fc777006a9c0e Mon Sep 17 00:00:00 2001
-From: Chris Withers <chris@simplistix.co.uk>
-Date: Tue, 5 Oct 2021 10:42:15 +0100
-Subject: [PATCH] Restructure tests to clarify that the line numbers and
- filenames need to be correct in exceptions.
-
----
- tests/helpers.py | 10 ++++++++
- tests/samples/codeblock_future_imports.txt | 4 +--
- tests/test_codeblock.py | 30 ++++++++--------------
- 3 files changed, 22 insertions(+), 22 deletions(-)
-
-diff --git a/tests/helpers.py b/tests/helpers.py
-index 1f3d7dc..d96fe56 100644
---- a/tests/helpers.py
-+++ b/tests/helpers.py
-@@ -1,5 +1,8 @@
- from io import open
- from os.path import dirname, join
-+from traceback import TracebackException
-+
-+from _pytest._code import ExceptionInfo
-
- from sybil.document import Document
- from sybil.example import Example
-@@ -23,3 +26,10 @@ def evaluate_region(region, namespace):
- region=region,
- namespace=namespace
- ))
-+
-+
-+def check_excinfo(excinfo: ExceptionInfo, text: str, *, lineno: int, filename: str = '/the/path'):
-+ assert str(excinfo.value) == text, f'{str(excinfo.value)!r} == {text!r}'
-+ details = TracebackException.from_exception(excinfo.value, lookup_lines=False).stack[-1]
-+ assert details.filename == filename, f'{details.filename!r} == {filename!r}'
-+ assert details.lineno == lineno, f'{details.lineno} == {lineno}'
-diff --git a/tests/samples/codeblock_future_imports.txt b/tests/samples/codeblock_future_imports.txt
-index c59a541..22412ed 100644
---- a/tests/samples/codeblock_future_imports.txt
-+++ b/tests/samples/codeblock_future_imports.txt
-@@ -1,9 +1,9 @@
- .. invisible-code-block: python
-
-- print('pathalogical worst case for line numbers', file=buffer)
-+ raise Exception('Boom 1')
-
- More likely is one down here:
-
- .. code-block:: python
-
-- print('still should work and have good line numbers', file=buffer)
-+ raise Exception('Boom 2')
-diff --git a/tests/test_codeblock.py b/tests/test_codeblock.py
-index 9196fb5..9aab10e 100644
---- a/tests/test_codeblock.py
-+++ b/tests/test_codeblock.py
-@@ -2,7 +2,7 @@
- from io import StringIO
- from sybil.document import Document
- from sybil.parsers.codeblock import CodeBlockParser, compile_codeblock
--from tests.helpers import document_from_sample, evaluate_region
-+from .helpers import document_from_sample, evaluate_region, check_excinfo
-
-
- def test_basic():
-@@ -16,7 +16,7 @@ def test_basic():
- assert namespace['z'] == 0
- with pytest.raises(Exception) as excinfo:
- evaluate_region(regions[1], namespace)
-- assert str(excinfo.value) == 'boom!'
-+ check_excinfo(excinfo, 'boom!', lineno=11)
- assert evaluate_region(regions[2], namespace) is None
- assert namespace['y'] == 1
- assert namespace['z'] == 1
-@@ -32,27 +32,17 @@ def test_basic():
- assert '__builtins__' not in namespace
-
-
--def test_future_imports():
-+def test_line_numbers_correct_with_future_imports():
- document = document_from_sample('codeblock_future_imports.txt')
- regions = list(CodeBlockParser(['print_function'])(document))
- assert len(regions) == 2
-- buffer = StringIO()
-- namespace = {'buffer': buffer}
-- assert evaluate_region(regions[0], namespace) is None
-- assert buffer.getvalue() == (
-- 'pathalogical worst case for line numbers\n'
-- )
-- # the future import line drops the firstlineno by 1
-- code = compile_codeblock(regions[0].parsed, document.path)
-- assert code.co_firstlineno == 2
-- assert evaluate_region(regions[1], namespace) is None
-- assert buffer.getvalue() == (
-- 'pathalogical worst case for line numbers\n'
-- 'still should work and have good line numbers\n'
-- )
-- # the future import line drops the firstlineno by 1
-- code = compile_codeblock(regions[1].parsed, document.path)
-- assert code.co_firstlineno == 8
-+ namespace = {}
-+ with pytest.raises(Exception) as excinfo:
-+ evaluate_region(regions[0], namespace)
-+ check_excinfo(excinfo, 'Boom 1', lineno=3)
-+ with pytest.raises(Exception) as excinfo:
-+ evaluate_region(regions[1], namespace)
-+ check_excinfo(excinfo, 'Boom 2', lineno=9)
-
-
- def test_windows_line_endings(tmp_path):