14
0
forked from pool/python-Sphinx

Accepting request 359916 from home:TheBlackCat:branches:devel:languages:python

Add fix_some_testcase_error_with_pygments-2.1.1.patch
Fixes tests with python-Pygments 2.1.1.

OBS-URL: https://build.opensuse.org/request/show/359916
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Sphinx?expand=0&rev=71
This commit is contained in:
Todd R
2016-02-17 09:13:39 +00:00
committed by Git OBS Bridge
parent b51e64f6b4
commit fcf26c39ec
3 changed files with 68 additions and 11 deletions

View File

@@ -0,0 +1,39 @@
From 50f4862b069d58ade556aad90bd179206f10fdc1 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Mon, 15 Feb 2016 11:46:30 +0900
Subject: [PATCH] Fix some testcase get error with pygments-2.1.1
---
tests/test_build_html.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index b97d9d5..c11ad68 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -344,12 +344,23 @@ def check_xpath(etree, fname, path, check, be_found=True):
# only check for node presence
pass
else:
+ def get_text(node):
+ if node.text is not None:
+ return node.text
+ else:
+ # Since pygments-2.1.1, empty <span> tag is inserted at top of
+ # highlighting block
+ if len(node) == 1 and node[0].tag == 'span' and node[0].text is None:
+ return node[0].tail
+ else:
+ return ''
+
rex = re.compile(check)
if be_found:
- if any(node.text and rex.search(node.text) for node in nodes):
+ if any(rex.search(get_text(node)) for node in nodes):
return
else:
- if all(node.text and not rex.search(node.text) for node in nodes):
+ if all(not rex.search(get_text(node)) for node in nodes):
return
assert False, ('%r not found in any node matching '