chiark / gitweb /
m.plots: work around test failure on Travis.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 16 May 2018 10:12:48 +0000 (12:12 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Wed, 16 May 2018 10:20:49 +0000 (12:20 +0200)
Only one ID is different, which is still okay to validate a separate
test case.

package/ci/travis.yml
pelican-plugins/m/test/plots/page-travis-broken-matplotlib-seed.html [new file with mode: 0644]
pelican-plugins/m/test/test_plots.py

index d41b662b9a1d829c4edebaa7d3b74ea865d82a5b..9bbeb2d56c5a93eb5b532b005a5d11c6e3fb8b4e 100644 (file)
@@ -8,6 +8,7 @@ matrix:
       - WITH_THEME=ON
       - WITH_DOXYGEN=OFF
       - WITH_NODE=OFF
+      - TRAVIS_BROKEN_MATPLOTLIB_SEED=YES
       - JOBID=py34
     - language: python
       python: 3.5
@@ -22,6 +23,7 @@ matrix:
       - WITH_THEME=ON
       - WITH_DOXYGEN=ON
       - WITH_NODE=OFF
+      - TRAVIS_BROKEN_MATPLOTLIB_SEED=YES
       - JOBID=py36
     - language: node_js
       node_js: 8
diff --git a/pelican-plugins/m/test/plots/page-travis-broken-matplotlib-seed.html b/pelican-plugins/m/test/plots/page-travis-broken-matplotlib-seed.html
new file mode 100644 (file)
index 0000000..c676996
--- /dev/null
@@ -0,0 +1,353 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>m.plots | A Pelican Blog</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i" />
+  <link rel="stylesheet" href="static/m-dark.css" />
+  <link rel="canonical" href="page.html" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="./" id="m-navbar-brand" class="m-col-t-9 m-col-m-none m-left-m">A Pelican Blog</a>
+    </div>
+  </div>
+</nav></header>
+<main>
+<article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>m.plots</h1>
+<!-- content -->
+<p>Note: the test uses DejaVu Sans instead of Source Sans Pro in order to have
+predictable rendering on the CIs.</p>
+<style>
+div.m-plot svg { font-family: DejaVu Sans; }
+</style><div class="m-plot">
+<svg viewBox="0 0 576 113.76">
+ <defs>
+  <style type="text/css">
+*{stroke-linecap:butt;stroke-linejoin:round;}
+  </style>
+ </defs>
+ <g id="figure_1">
+  <g id="axes_1">
+   <g id="patch_1">
+    <path d="M 59.365156 69.588125 L 560.62 69.588125 L 560.62 27.757969 L 59.365156 27.757969 z" class="m-background"/>
+   </g>
+   <g id="plot1-value0"><title>15.0 meters, i guess?</title>
+    <path clip-path="url(#p372224c2cf)" d="M 59.365156 29.659339 L 298.057939 29.659339 L 298.057939 46.560413 L 59.365156 46.560413 z" class="m-bar m-success"/>
+   </g>
+   <g id="plot1-value1"><title>30.0 meters, i guess?</title>
+    <path clip-path="url(#p372224c2cf)" d="M 59.365156 50.785681 L 536.750722 50.785681 L 536.750722 67.686754 L 59.365156 67.686754 z" class="m-bar m-success"/>
+   </g>
+   <g id="matplotlib.axis_1">
+    <g id="xtick_1">
+     <g id="line2d_1">
+      <defs>
+       <path d="M 0 0 L 0 3.5" id="m15f0a304df" class="m-line"/>
+      </defs>
+      <g>
+       <use x="59.365156" xlink:href="#m15f0a304df" y="69.588125"/>
+      </g>
+     </g>
+     <g id="text_1">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 59.365156, 84.946406)" x="59.365156" y="84.946406">0</text>
+     </g>
+    </g>
+    <g id="xtick_2">
+     <g id="line2d_2">
+      <g>
+       <use x="138.929417" xlink:href="#m15f0a304df" y="69.588125"/>
+      </g>
+     </g>
+     <g id="text_2">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 138.929417, 84.946406)" x="138.929417" y="84.946406">5</text>
+     </g>
+    </g>
+    <g id="xtick_3">
+     <g id="line2d_3">
+      <g>
+       <use x="218.493678" xlink:href="#m15f0a304df" y="69.588125"/>
+      </g>
+     </g>
+     <g id="text_3">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 218.493678, 84.946406)" x="218.493678" y="84.946406">10</text>
+     </g>
+    </g>
+    <g id="xtick_4">
+     <g id="line2d_4">
+      <g>
+       <use x="298.057939" xlink:href="#m15f0a304df" y="69.588125"/>
+      </g>
+     </g>
+     <g id="text_4">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 298.057939, 84.946406)" x="298.057939" y="84.946406">15</text>
+     </g>
+    </g>
+    <g id="xtick_5">
+     <g id="line2d_5">
+      <g>
+       <use x="377.6222" xlink:href="#m15f0a304df" y="69.588125"/>
+      </g>
+     </g>
+     <g id="text_5">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 377.6222, 84.946406)" x="377.6222" y="84.946406">20</text>
+     </g>
+    </g>
+    <g id="xtick_6">
+     <g id="line2d_6">
+      <g>
+       <use x="457.186461" xlink:href="#m15f0a304df" y="69.588125"/>
+      </g>
+     </g>
+     <g id="text_6">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 457.186461, 84.946406)" x="457.186461" y="84.946406">25</text>
+     </g>
+    </g>
+    <g id="xtick_7">
+     <g id="line2d_7">
+      <g>
+       <use x="536.750722" xlink:href="#m15f0a304df" y="69.588125"/>
+      </g>
+     </g>
+     <g id="text_7">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 536.750722, 84.946406)" x="536.750722" y="84.946406">30</text>
+     </g>
+    </g>
+    <g id="text_8">
+     <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 309.992578, 99.592344)" x="309.992578" y="99.592344">meters, i guess?</text>
+    </g>
+   </g>
+   <g id="matplotlib.axis_2">
+    <g id="ytick_1">
+     <g id="line2d_8">
+      <defs>
+       <path d="M 0 0 L -3.5 0" id="mba4ce04b6c" class="m-line"/>
+      </defs>
+      <g>
+       <use x="59.365156" xlink:href="#mba4ce04b6c" y="38.109876"/>
+      </g>
+     </g>
+     <g id="text_9">
+      <text class="m-label" style="text-anchor:end;" transform="rotate(-0, 52.365156, 42.289017)" x="52.365156" y="42.289017">First</text>
+     </g>
+    </g>
+    <g id="ytick_2">
+     <g id="line2d_9">
+      <g>
+       <use x="59.365156" xlink:href="#mba4ce04b6c" y="59.236218"/>
+      </g>
+     </g>
+     <g id="text_10">
+      <text class="m-label" style="text-anchor:end;" transform="rotate(-0, 52.365156, 63.415358)" x="52.365156" y="63.415358">Second</text>
+     </g>
+    </g>
+   </g>
+   <g id="text_11">
+    <text class="m-title" style="text-anchor:middle;" transform="rotate(-0, 309.992578, 21.757969)" x="309.992578" y="21.757969">A plot with a single color</text>
+   </g>
+  </g>
+ </g>
+ <defs>
+  <clipPath id="p372224c2cf">
+   <rect height="41.830156" width="501.254844" x="59.365156" y="27.757969"/>
+  </clipPath>
+ </defs>
+</svg>
+</div>
+<div class="m-plot">
+<svg viewBox="0 0 576 218.16">
+ <defs>
+  <style type="text/css">
+*{stroke-linecap:butt;stroke-linejoin:round;}
+  </style>
+ </defs>
+ <g id="figure_1">
+  <g id="axes_1">
+   <g id="patch_1">
+    <path d="M 68.216719 173.988125 L 558.482422 173.988125 L 558.482422 27.757969 L 68.216719 27.757969 z" class="m-background"/>
+   </g>
+   <g id="plot2-value0"><title>3.0 ± 0.1 Mondays</title>
+    <path clip-path="url(#p3046aeaf3f)" d="M 68.216719 34.404794 L 297.849367 34.404794 L 297.849367 72.386653 L 68.216719 72.386653 z" class="m-bar m-success"/>
+   </g>
+   <g id="plot2-value1"><title>4.0 ± 2.1 Mondays</title>
+    <path clip-path="url(#p3046aeaf3f)" d="M 68.216719 81.882117 L 374.393583 81.882117 L 374.393583 119.863976 L 68.216719 119.863976 z" class="m-bar m-info"/>
+   </g>
+   <g id="plot2-value2"><title>5.0 ± 1.0 Mondays</title>
+    <path clip-path="url(#p3046aeaf3f)" d="M 68.216719 129.359441 L 450.937798 129.359441 L 450.937798 167.3413 L 68.216719 167.3413 z" class="m-bar m-danger"/>
+   </g>
+   <g id="matplotlib.axis_1">
+    <g id="xtick_1">
+     <g id="line2d_1">
+      <defs>
+       <path d="M 0 0 L 0 3.5" id="m7a9c636c50" class="m-line"/>
+      </defs>
+      <g>
+       <use x="68.216719" xlink:href="#m7a9c636c50" y="173.988125"/>
+      </g>
+     </g>
+     <g id="text_1">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 68.216719, 189.346406)" x="68.216719" y="189.346406">0</text>
+     </g>
+    </g>
+    <g id="xtick_2">
+     <g id="line2d_2">
+      <g>
+       <use x="144.760935" xlink:href="#m7a9c636c50" y="173.988125"/>
+      </g>
+     </g>
+     <g id="text_2">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 144.760935, 189.346406)" x="144.760935" y="189.346406">1</text>
+     </g>
+    </g>
+    <g id="xtick_3">
+     <g id="line2d_3">
+      <g>
+       <use x="221.305151" xlink:href="#m7a9c636c50" y="173.988125"/>
+      </g>
+     </g>
+     <g id="text_3">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 221.305151, 189.346406)" x="221.305151" y="189.346406">2</text>
+     </g>
+    </g>
+    <g id="xtick_4">
+     <g id="line2d_4">
+      <g>
+       <use x="297.849367" xlink:href="#m7a9c636c50" y="173.988125"/>
+      </g>
+     </g>
+     <g id="text_4">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 297.849367, 189.346406)" x="297.849367" y="189.346406">3</text>
+     </g>
+    </g>
+    <g id="xtick_5">
+     <g id="line2d_5">
+      <g>
+       <use x="374.393583" xlink:href="#m7a9c636c50" y="173.988125"/>
+      </g>
+     </g>
+     <g id="text_5">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 374.393583, 189.346406)" x="374.393583" y="189.346406">4</text>
+     </g>
+    </g>
+    <g id="xtick_6">
+     <g id="line2d_6">
+      <g>
+       <use x="450.937798" xlink:href="#m7a9c636c50" y="173.988125"/>
+      </g>
+     </g>
+     <g id="text_6">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 450.937798, 189.346406)" x="450.937798" y="189.346406">5</text>
+     </g>
+    </g>
+    <g id="xtick_7">
+     <g id="line2d_7">
+      <g>
+       <use x="527.482014" xlink:href="#m7a9c636c50" y="173.988125"/>
+      </g>
+     </g>
+     <g id="text_7">
+      <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 527.482014, 189.346406)" x="527.482014" y="189.346406">6</text>
+     </g>
+    </g>
+    <g id="text_8">
+     <text class="m-label" style="text-anchor:middle;" transform="rotate(-0, 313.34957, 203.992344)" x="313.34957" y="203.992344">Mondays</text>
+    </g>
+   </g>
+   <g id="matplotlib.axis_2">
+    <g id="ytick_1">
+     <g id="line2d_8">
+      <defs>
+       <path d="M 0 0 L -3.5 0" id="m03b20617ea" class="m-line"/>
+      </defs>
+      <g>
+       <use x="68.216719" xlink:href="#m03b20617ea" y="53.395723"/>
+      </g>
+     </g>
+     <g id="text_9">
+      <text class="m-label" transform="translate(19.514688 51.416067)">January</text>
+      <text class="m-label" transform="translate(61.216719 63.733661)"/>
+     </g>
+    </g>
+    <g id="ytick_2">
+     <g id="line2d_9">
+      <g>
+       <use x="68.216719" xlink:href="#m03b20617ea" y="100.873047"/>
+      </g>
+     </g>
+     <g id="text_10">
+      <text class="m-label" transform="translate(11.88 98.893391)">February</text>
+      <text class="m-label" transform="translate(61.216719 111.210984)"/>
+     </g>
+    </g>
+    <g id="ytick_3">
+     <g id="line2d_10">
+      <g>
+       <use x="68.216719" xlink:href="#m03b20617ea" y="148.35037"/>
+      </g>
+     </g>
+     <g id="text_11">
+      <text class="m-label" transform="translate(27.446719 146.370714)">March</text>
+      <text class="m-label" transform="translate(61.216719 158.688308)"/>
+     </g>
+    </g>
+   </g>
+   <g id="LineCollection_1">
+    <path clip-path="url(#p3046aeaf3f)" d="M 290.194945 53.395723 L 305.503788 53.395723" class="m-error"/>
+    <path clip-path="url(#p3046aeaf3f)" d="M 213.650729 100.873047 L 535.136436 100.873047" class="m-error"/>
+    <path clip-path="url(#p3046aeaf3f)" d="M 374.393583 148.35037 L 527.482014 148.35037" class="m-error"/>
+   </g>
+   <g id="line2d_11">
+    <defs>
+     <path d="M 0 9.375 L 0 -9.375" id="m63fa77ade3" class="m-error"/>
+    </defs>
+    <g clip-path="url(#p3046aeaf3f)">
+     <use x="290.194945" xlink:href="#m63fa77ade3" y="53.395723"/>
+     <use x="213.650729" xlink:href="#m63fa77ade3" y="100.873047"/>
+     <use x="374.393583" xlink:href="#m63fa77ade3" y="148.35037"/>
+    </g>
+   </g>
+   <g id="line2d_12">
+    <g clip-path="url(#p3046aeaf3f)">
+     <use x="305.503788" xlink:href="#m63fa77ade3" y="53.395723"/>
+     <use x="535.136436" xlink:href="#m63fa77ade3" y="100.873047"/>
+     <use x="527.482014" xlink:href="#m63fa77ade3" y="148.35037"/>
+    </g>
+   </g>
+   <g id="text_12">
+    <text class="m-label m-dim" transform="translate(61.216719 52.646105)"/>
+    <text class="m-label m-dim" transform="translate(3.454687 64.963699)">a paradise</text>
+   </g>
+   <g id="text_13">
+    <text class="m-label m-dim" transform="translate(61.216719 100.123429)"/>
+    <text class="m-label m-dim" transform="translate(34.866563 112.441022)">okay</text>
+   </g>
+   <g id="text_14">
+    <text class="m-label m-dim" transform="translate(61.216719 147.600752)"/>
+    <text class="m-label m-dim" transform="translate(36.954844 159.918346)">hell!</text>
+   </g>
+   <g id="text_15">
+    <text class="m-title" style="text-anchor:middle;" transform="rotate(-0, 313.34957, 21.757969)" x="313.34957" y="21.757969">A plot with separate colors, extra labels, error bars and custom height</text>
+   </g>
+  </g>
+ </g>
+ <defs>
+  <clipPath id="p3046aeaf3f">
+   <rect height="146.230156" width="490.265703" x="68.216719" y="27.757969"/>
+  </clipPath>
+ </defs>
+</svg>
+</div>
+<!-- /content -->
+      </div>
+    </div>
+  </div>
+</article>
+</main>
+</body>
+</html>
index e9a7a87f2235d664becf4323d214a781ad8b1358..40f40d9797efdf96b9fe48be462e76cbdd4aa0a3 100644 (file)
 #   DEALINGS IN THE SOFTWARE.
 #
 
+import os
+import unittest
+
 from . import PluginTestCase
 
 class Plots(PluginTestCase):
     def __init__(self, *args, **kwargs):
         super().__init__(__file__, '', *args, **kwargs)
 
+    @unittest.skipIf(os.environ.get('TRAVIS_BROKEN_MATPLOTLIB_SEED'),
+        "Travis Python 3.4 and 3.6 has broken matplotlib seed, causing different clip-path ID")
     def test(self):
         self.run_pelican({
             'PLUGINS': ['m.htmlsanity', 'm.plots'],
@@ -35,3 +40,13 @@ class Plots(PluginTestCase):
         })
 
         self.assertEqual(*self.actual_expected_contents('page.html'))
+
+    @unittest.skipUnless(os.environ.get('TRAVIS_BROKEN_MATPLOTLIB_SEED'),
+        "Travis Python 3.4 and 3.6 has different matplotlib seed, causing different clip-path ID")
+    def test_broken_seed(self):
+        self.run_pelican({
+            'PLUGINS': ['m.htmlsanity', 'm.plots'],
+            'M_PLOTS_FONT': 'DejaVu Sans'
+        })
+
+        self.assertEqual(*self.actual_expected_contents('page.html', 'page-travis-broken-matplotlib-seed.html'))