[python-behave] Add two patches provided by Vadim Rutkovsky (fix #1058371 and #1067388)
Matej Cepl
mcepl at fedoraproject.org
Wed Mar 12 10:31:44 UTC 2014
commit 43f5c7ee86af0de237b7c6d650face734a0c38b5
Author: Matěj Cepl <mcepl at redhat.com>
Date: Wed Mar 12 11:31:03 2014 +0100
Add two patches provided by Vadim Rutkovsky (fix #1058371 and #1067388)
...dding-support-link-caption-and-video-tags.patch | 113 ++++++++++++++++++++
0001-HTML-Formatter.patch => HTML-Formatter.patch | 0
...ter-strip-incorrect-chars-from-error-mess.patch | 55 ++++++++++
python-behave.spec | 14 ++-
4 files changed, 180 insertions(+), 2 deletions(-)
---
diff --git a/Embedding-support-link-caption-and-video-tags.patch b/Embedding-support-link-caption-and-video-tags.patch
new file mode 100644
index 0000000..9b499a9
--- /dev/null
+++ b/Embedding-support-link-caption-and-video-tags.patch
@@ -0,0 +1,113 @@
+From 785a8311e3c4af8b172034f7223f50c6db840f4c Mon Sep 17 00:00:00 2001
+From: Vadim Rutkovsky <vrutkovs at redhat.com>
+Date: Mon, 27 Jan 2014 17:27:04 +0100
+Subject: [PATCH] Embedding: support link caption and video tags
+
+---
+ behave/formatter/html.py | 36 ++++++++++++++++++++++++++++++------
+ behave/formatter/json.py | 2 +-
+ behave/runner.py | 4 ++--
+ 3 files changed, 33 insertions(+), 9 deletions(-)
+
+--- a/behave/formatter/html.py
++++ b/behave/formatter/html.py
+@@ -227,10 +227,11 @@ class HTMLFormatter(Formatter):
+ if hasattr(self, 'embed_in_this_step') and self.embed_in_this_step:
+ self._doEmbed(self.last_step_embed_span,
+ self.embed_mime_type,
+- self.embed_data)
++ self.embed_data,
++ self.embed_caption)
+ self.embed_in_this_step = None
+
+- def _doEmbed(self, span, mime_type, data):
++ def _doEmbed(self, span, mime_type, data, caption):
+ self.embed_id += 1
+
+ link = ET.SubElement(span, 'a')
+@@ -240,8 +241,28 @@ class HTMLFormatter(Formatter):
+ "(embd.style.display == 'none' ? 'block' : 'none');" +
+ "return false")
+
++ if 'video/' in mime_type:
++ if not caption:
++ caption = u'Video'
++ link.text = unicode(caption)
++
++ embed = ET.SubElement(span, 'video',
++ {'id': 'embed_%s' % self.embed_id,
++ 'style': 'display: none',
++ 'width': '320',
++ 'controls': '',
++ })
++ embed.tail = u' '
++ embed_source = ET.SubElement(embed, 'source',
++ {
++ 'src': u'data:%s;base64,%s' % (mime_type, base64.b64encode(data)),
++ 'type': '%s; codecs="vp8 vorbis"' % mime_type
++ })
++
+ if 'image/' in mime_type:
+- link.text = u'Screenshot'
++ if not caption:
++ caption = u'Screenshot'
++ link.text = unicode(caption)
+
+ embed = ET.SubElement(span, 'img',
+ {'id': 'embed_%s' % self.embed_id,
+@@ -251,7 +272,9 @@ class HTMLFormatter(Formatter):
+ embed.tail = u' '
+
+ if 'text/' in mime_type:
+- link.text = u'Data'
++ if not caption:
++ caption = u'Data'
++ link.text = unicode(caption)
+
+ cleaned_data = ''.join(
+ c for c in data if _valid_XML_char_ordinal(ord(c))
+@@ -263,15 +286,16 @@ class HTMLFormatter(Formatter):
+ embed.text = cleaned_data
+ embed.tail = u' '
+
+- def embedding(self, mime_type, data):
++ def embedding(self, mime_type, data, caption=None):
+ if self.last_step.status == 'untested':
+ # Embed called during step execution
+ self.embed_in_this_step = True
+ self.embed_mime_type = mime_type
+ self.embed_data = data
++ self.embed_caption = caption
+ else:
+ # Embed called in after_*
+- self._doEmbed(self.last_step_embed_span, mime_type, data)
++ self._doEmbed(self.last_step_embed_span, mime_type, data, caption)
+
+ def close(self):
+ if not hasattr(self, "all_features"):
+--- a/behave/formatter/json.py
++++ b/behave/formatter/json.py
+@@ -170,7 +170,7 @@ class JSONFormatter(Formatter):
+ result_element['error_message'] = error_message
+ self._step_index += 1
+
+- def embedding(self, mime_type, data):
++ def embedding(self, mime_type, data, caption=None):
+ step = self.current_feature_element['steps'][-1]
+ step['embeddings'].append({
+ 'mime_type': mime_type,
+--- a/behave/runner.py
++++ b/behave/runner.py
+@@ -241,10 +241,10 @@ class Context(object):
+ return True
+ return False
+
+- def embed(self, mime_type, data):
++ def embed(self, mime_type, data, caption=None):
+ for formatter in self._runner.formatters:
+ if hasattr(formatter, 'embedding'):
+- formatter.embedding(mime_type, data)
++ formatter.embedding(mime_type, data, caption)
+
+ def execute_steps(self, steps_text):
+ '''The steps identified in the "steps" text string will be parsed and
diff --git a/0001-HTML-Formatter.patch b/HTML-Formatter.patch
similarity index 100%
rename from 0001-HTML-Formatter.patch
rename to HTML-Formatter.patch
diff --git a/html-formatter-strip-incorrect-chars-from-error-mess.patch b/html-formatter-strip-incorrect-chars-from-error-mess.patch
new file mode 100644
index 0000000..b952516
--- /dev/null
+++ b/html-formatter-strip-incorrect-chars-from-error-mess.patch
@@ -0,0 +1,55 @@
+From f5ffd5e581af27999c475cb3f74d69981cc758c0 Mon Sep 17 00:00:00 2001
+From: Vadim Rutkovsky <vrutkovs at redhat.com>
+Date: Thu, 20 Feb 2014 12:06:25 +0100
+Subject: [PATCH] html formatter: strip incorrect chars from error message
+
+---
+ behave/formatter/html.py | 20 ++++++++++++--------
+ 1 file changed, 12 insertions(+), 8 deletions(-)
+
+--- a/behave/formatter/html.py
++++ b/behave/formatter/html.py
+@@ -4,6 +4,14 @@ import base64
+ import os.path
+ from behave.compat.collections import Counter
+
++def _valid_XML_char_ordinal(i):
++ return ( # conditions ordered by presumed frequency
++ 0x20 <= i <= 0xD7FF
++ or i in (0x9, 0xA, 0xD)
++ or 0xE000 <= i <= 0xFFFD
++ or 0x10000 <= i <= 0x10FFFF
++ )
++
+
+ class HTMLFormatter(Formatter):
+ name = 'html'
+@@ -200,7 +208,10 @@ class HTMLFormatter(Formatter):
+ embed = ET.SubElement(step, 'pre',
+ {'id': "embed_%s" % self.embed_id,
+ 'style': 'display: none; white-space: pre-wrap;'})
+- embed.text = result.error_message
++ cleaned_error_message = ''.join(
++ c for c in result.error_message if valid_XML_char_ordinal(ord(c))
++ )
++ embed.text = cleaned_error_message
+ embed.tail = u' '
+
+ if result.status == 'failed':
+@@ -242,15 +253,8 @@ class HTMLFormatter(Formatter):
+ if 'text/' in mime_type:
+ link.text = u'Data'
+
+- def valid_XML_char_ordinal(i):
+- return ( # conditions ordered by presumed frequency
+- 0x20 <= i <= 0xD7FF
+- or i in (0x9, 0xA, 0xD)
+- or 0xE000 <= i <= 0xFFFD
+- or 0x10000 <= i <= 0x10FFFF
+- )
+ cleaned_data = ''.join(
+- c for c in data if valid_XML_char_ordinal(ord(c))
++ c for c in data if _valid_XML_char_ordinal(ord(c))
+ )
+
+ embed = ET.SubElement(span, 'pre',
diff --git a/python-behave.spec b/python-behave.spec
index 99419e3..312095d 100644
--- a/python-behave.spec
+++ b/python-behave.spec
@@ -12,7 +12,7 @@
Name: python-%{modname}
Version: 1.2.3
-Release: 8%{?dist}
+Release: 9%{?dist}
Summary: Tools for the behavior-driven development, Python style
License: BSD
@@ -20,7 +20,11 @@ URL: http://pypi.python.org/pypi/%{modname}
Source0: http://pypi.python.org/packages/source/b/%{modname}/%{modname}-%{version}.tar.gz
# Pending pull request in the upstream repository
# https://github.com/behave/behave/pull/86
-Patch0: 0001-HTML-Formatter.patch
+Patch0: HTML-Formatter.patch
+# Fix for RHBZ# 1067388
+Patch1: html-formatter-strip-incorrect-chars-from-error-mess.patch
+# Fix for RHBZ# 1058371
+Patch2: Embedding-support-link-caption-and-video-tags.patch
BuildArch: noarch
%if %{with testsuite}
@@ -74,6 +78,8 @@ brief feature-examples.
%prep
%setup -q -n %{modname}-%{version}
%patch0 -p1 -b .HTMLformatter
+%patch1 -p1 -b .HTMLformatterFixUTF8
+%patch2 -p1 -b .EmbeddedVideo
# Remove bundled egg-info in case it exists
rm -rf %{modname}*.egg-info
@@ -143,6 +149,10 @@ nosetests -v
%changelog
+* Wed Mar 12 2014 Matěj Cepl <mcepl at redhat.com> - 1.2.3-9
+- Add two patches provided by Vadim Rutkovsky (fix #1058371 and
+ #1067388)
+
* Tue Oct 29 2013 Matěj Cepl <mcepl at redhat.com> - 1.2.3-8
- Add Vadim Rutkovsky’s HTML Formatter patch (fix #1024023)
More information about the scm-commits
mailing list