File: Prevent_division_by_zero_in_tests.patch

package info (click to toggle)
python-pyeclib 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,632 kB
  • ctags: 405
  • sloc: python: 2,184; ansic: 991; sh: 59; makefile: 53
file content (29 lines) | stat: -rw-r--r-- 934 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From ee6e409d835f2ca4a3e0c7757761a8f2ebd680ed Mon Sep 17 00:00:00 2001
From: Ondřej Nový <ondrej.novy@firma.seznam.cz>
Date: Thu, 15 Dec 2016 16:37:14 +0100
Subject: [PATCH] Prevent division by zero in tests

If avg_time is 0, tests will fail:
throughput = (size / 1000.0) / avg_time
ZeroDivisionError: float division by zero

This happens for me on Hurd:
https://buildd.debian.org/status/fetch.php?pkg=python-pyeclib&arch=hurd-i386&ver=1.3.1-1&stamp=1475967332

Change-Id: I0a7812977173b37918f40891f6ec0a2bc7c1d023
---

diff --git a/test/test_pyeclib_c.py b/test/test_pyeclib_c.py
index 1e44214..0395e21 100644
--- a/test/test_pyeclib_c.py
+++ b/test/test_pyeclib_c.py
@@ -289,6 +289,9 @@
         size_desc = size_str.split("-")
         size = float(size_desc[0])
 
+        if avg_time == 0:
+            return '?'
+
         if size_desc[1] == 'M':
             throughput = size / avg_time
         elif size_desc[1] == 'K':