Live patch junitxml lib to include skipped tests
Patch copied from
https://bugs.launchpad.net/pyjunitxml/+bug/1243928
Change-Id: Ic13e4d13597674b72399b4d45e340127e96824aa
Closes-Issue: PROD-19250
diff --git a/Dockerfile b/Dockerfile
index 48e8c0e..6a22a44 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,7 +30,7 @@
&& echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > apt.conf.d/docker-gzip-indexes \
&& echo 'APT::Get::Install-Recommends "false"; APT::Get::Install-Suggests "false";' > apt.conf.d/docker-recommends \
&& apt-get update && apt-get upgrade -y \
- && apt-get install -y vim-tiny git-core python-pip libffi-dev libssl-dev python-dev python3-dev iputils-ping
+ && apt-get install -y vim-tiny git-core python-pip libffi-dev libssl-dev python-dev python3-dev iputils-ping patch
RUN pip install -U pip
WORKDIR /var/lib/
@@ -82,6 +82,9 @@
pip install . ; popd;
RUN pip install junitxml
+# Patch junitxml library to include skipped tests in the test report totals header
+COPY bin/patches/junitxml_init.patch /tmp/junitxml_init.patch
+RUN patch /usr/local/lib/python2.7/dist-packages/junitxml/__init__.py /tmp/junitxml_init.patch
# Cleanup.
RUN apt-get -y purge libx11-data xauth libxmuu1 libxcb1 libx11-6 libxext6 \
diff --git a/bin/patches/junitxml_init.patch b/bin/patches/junitxml_init.patch
new file mode 100644
index 0000000..c8ec4ca
--- /dev/null
+++ b/bin/patches/junitxml_init.patch
@@ -0,0 +1,22 @@
+--- junitxml/__init__.py 2018-04-12 15:13:39.394382000 +0300
++++ junitxml/__init__.py 2018-04-12 16:58:12.288281319 +0300
+@@ -165,10 +165,16 @@
+ run.
+ """
+ duration = self._duration(self._run_start)
+- self._stream.write('<testsuite errors="%d" failures="%d" name="" '
+- 'tests="%d" time="%0.3f">\n' % (len(self.errors),
++
++ if len(self.skipped) == 0:
++ skipped = ""
++ else:
++ skipped = 'skipped="{}" '.format(len(self.skipped))
++
++ self._stream.write('<testsuite errors="%d" failures="%d"'
++ ' skipped="%d" name="" tests="%d" time="%0.3f">\n' % (len(self.errors),
+ len(self.failures) + len(getattr(self, "unexpectedSuccesses", ())),
+- self.testsRun, duration))
++ len(self.skipped), self.testsRun, duration))
+ self._stream.write(''.join(self._results))
+ self._stream.write('</testsuite>\n')
+