[PATCH] ui: fix configwith doctest

Jun Wu quark at fb.com
Tue Feb 14 05:05:43 UTC 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1487048450 28800
#      Mon Feb 13 21:00:50 2017 -0800
# Node ID ba4d509ef528627871e26172fcf9cfd71c2195c4
# Parent  f2ad0d8047009e6e58ab1fa34ae7107714f5dc30
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r ba4d509ef528
ui: fix configwith doctest

4.2 cannot be expressed with IEEE floating point losslessly, and could
cause test failure on some platform:

    File ".../mercurial/ui.py", line 414, in mercurial.ui.ui.configwith
    Failed example:
        u.configwith(float, s, 'float2')
    Expected:
        -4.2
    Got:
        -4.2000000000000002

This patch fixes that by changing the number to 4.25, which can be expressed
by the binary number 100.01.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -411,7 +411,7 @@ class ui(object):
         >>> u.configwith(float, s, 'float1')
         42.0
-        >>> u.setconfig(s, 'float2', '-4.2')
+        >>> u.setconfig(s, 'float2', '-4.25')
         >>> u.configwith(float, s, 'float2')
-        -4.2
+        -4.25
         >>> u.configwith(float, s, 'unknown', 7)
         7


More information about the Mercurial-devel mailing list