[tor-commits] [bridgedb/master] Add Bridges.is_valid_ip doctests to b.p.addr.isValidIP docstring.

isis at torproject.org isis at torproject.org
Tue Feb 3 02:31:02 UTC 2015


commit 9ac16433baa073a03396d33cb4e2c5e23ccd5b82
Author: Isis Lovecruft <isis at torproject.org>
Date:   Mon Jun 9 22:18:34 2014 +0000

    Add Bridges.is_valid_ip doctests to b.p.addr.isValidIP docstring.
    
    Just to double check that they return the same expected results.
---
 lib/bridgedb/parse/addr.py |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/bridgedb/parse/addr.py b/lib/bridgedb/parse/addr.py
index f4cd805..ace4c80 100644
--- a/lib/bridgedb/parse/addr.py
+++ b/lib/bridgedb/parse/addr.py
@@ -320,6 +320,21 @@ def isIPAddress(ip, compressed=True):
 def _isIPv(version, ip):
     """Check if **ip** is a certain **version** (IPv4 or IPv6).
 
+    >>> from bridgedb.parse.addr import isValidIP
+    >>> isValidIP('1.2.3.4')
+    True
+    >>> isValidIP('1.2.3.255')
+    True
+    >>> isValidIP('1.2.3.256')
+    False
+    >>> isValidIP('1')
+    False
+    >>> isValidIP('1.2.3')
+    False
+    >>> isValidIP('xyzzy')
+    False
+
+
     .. warning: Do *not* put any calls to the logging module in this function,
         or else an infinite recursion will occur when the call is made, due
         the the log :class:`~logging.Filter`s in :mod:`~bridgedb.safelog`
@@ -329,7 +344,7 @@ def _isIPv(version, ip):
     :param integer version: The IPv[4|6] version to check; must be either
         ``4`` or ``6``. Any other value will be silently changed to ``4``.
     :param ip: The IP address to check. May be an any type which
-               :class:`ipaddr.IPAddress` will accept.
+        :class:`ipaddr.IPAddress` will accept.
     :rtype: boolean
     :returns: ``True``, if the address is an IPv4 address.
     """
@@ -383,8 +398,7 @@ def isValidIP(ip):
       * A :term:`Site-Local Address` or an :term:`Unique Local Address`.
 
     :type ip: An :class:`ipaddr.IPAddress`, :class:`ipaddr.IPv4Address`, or
-              :class:`ipaddr.IPv6Address`.
-
+        :class:`ipaddr.IPv6Address`.
     :param ip: An ``ipaddr.IPAddress`` class.
     :rtype: boolean
     :returns: ``True``, if **ip** passes the checks; False otherwise.





More information about the tor-commits mailing list