[Python-modules-commits] r31449 - in packages/python-dugong/trunk/debian (3 files)

nikratio-guest at users.alioth.debian.org nikratio-guest at users.alioth.debian.org
Fri Nov 14 23:26:47 UTC 2014


    Date: Friday, November 14, 2014 @ 23:26:46
  Author: nikratio-guest
Revision: 31449

Skip unit tests in test/test_examples.py. These tests require network
connectivity, and in addition to that the hardcoded remote server no
longer works (thus causing the tests to fail even if there is
connectivity). Closes: #769250

Added:
  packages/python-dugong/trunk/debian/patches/fix_test_examples.diff
Modified:
  packages/python-dugong/trunk/debian/changelog
  packages/python-dugong/trunk/debian/patches/series

Modified: packages/python-dugong/trunk/debian/changelog
===================================================================
--- packages/python-dugong/trunk/debian/changelog	2014-11-14 08:49:18 UTC (rev 31448)
+++ packages/python-dugong/trunk/debian/changelog	2014-11-14 23:26:46 UTC (rev 31449)
@@ -1,3 +1,12 @@
+python-dugong (3.3+dfsg-2) UNRELEASED; urgency=medium
+
+  * Skip unit tests in test/test_examples.py. These tests require network
+    connectivity, and in addition to that the hardcoded remote server no
+    longer works (thus causing the tests to fail even if there is
+    connectivity). Closes: #769250
+
+ -- Nikolaus Rath <Nikolaus at rath.org>  Fri, 14 Nov 2014 15:20:44 -0800
+
 python-dugong (3.3+dfsg-1) unstable; urgency=medium
 
   * New upstream release.

Added: packages/python-dugong/trunk/debian/patches/fix_test_examples.diff
===================================================================
--- packages/python-dugong/trunk/debian/patches/fix_test_examples.diff	                        (rev 0)
+++ packages/python-dugong/trunk/debian/patches/fix_test_examples.diff	2014-11-14 23:26:46 UTC (rev 31449)
@@ -0,0 +1,49 @@
+Author: Nikolaus Rath <Nikolaus at rath.org>
+Forwarded: not-needed
+Last-Update: 2014-11-14
+Description: Fix test skip conditions
+
+This patch ensures that tests requiring a hardcoded server to
+respond with a 200 status are properly skipped if the remote
+server returns a redirect instead.
+
+--- a/test/test_examples.py
++++ b/test/test_examples.py
+@@ -18,7 +18,8 @@
+ import os
+ import sys
+ import pytest
+-from urllib.request import build_opener, ProxyHandler, URLError
++from urllib.request import (build_opener, ProxyHandler, URLError, HTTPRedirectHandler,
++                            HTTPError)
+ try:
+     import asyncio
+ except ImportError:
+@@ -26,12 +27,24 @@
+ 
+ basename = os.path.join(os.path.dirname(__file__), '..')
+ 
++# Yes, this is the way to avoid following redirects with urllib,
++# and it is indeed absolutely terrible. But dependending on the
++# requests module just to run this simple test does not (yet)
++# seem appropriate either.
++class HTTPNoRedirectHandler(HTTPRedirectHandler):
++    def http_error_302(self, url, fp, errcode, errmsg, headers):
++        fp.close()
++        raise HTTPError(url, errcode, errmsg, headers, None)
++
++    http_error_301 = http_error_303 = http_error_307 = http_error_302
++
+ def check_url(url):
+     '''Skip test if *url* cannot be reached'''
+ 
+-    # Examples ignore proxy settings, so should urllib
+-    proxy_handler = ProxyHandler({})
+-    opener = build_opener(proxy_handler)
++    # To avoid using proxies (as the examples do), we need to add a proxy
++    # handler, but pass an empty dictionary for the proxy settings. urllib
++    # again...
++    opener = build_opener(ProxyHandler({}), HTTPNoRedirectHandler())
+ 
+     try:
+         resp = opener.open(url, None, 15)

Modified: packages/python-dugong/trunk/debian/patches/series
===================================================================
--- packages/python-dugong/trunk/debian/patches/series	2014-11-14 08:49:18 UTC (rev 31448)
+++ packages/python-dugong/trunk/debian/patches/series	2014-11-14 23:26:46 UTC (rev 31449)
@@ -1 +1,2 @@
+fix_test_examples.diff
 use-local-intersphinx.patch




More information about the Python-modules-commits mailing list