Permalink
Browse files

Skip test_bgzf.py if Python's gzip is broken

  • Loading branch information...
1 parent 859d07f commit 975f5c4f6422951ff2ac54bed6928312fdcd1a51 @peterjc peterjc committed May 14, 2013
Showing with 26 additions and 0 deletions.
  1. +26 −0 Tests/test_bgzf.py
View
@@ -18,6 +18,32 @@
from Bio import bgzf
+def _have_bug17666():
+ """Debug function to check if Python's gzip is broken (PRIVATE).
+
+ Checks for http://bugs.python.org/issue17666 expected in Python 2.7.4,
+ 3.2.4 and 3.3.1 only.
+ """
+ try:
+ #This is in Python 2.6+, but we need it on Python 3
+ from io import BytesIO
+ except ImportError:
+ from StringIO import StringIO as BytesIO
+ h = gzip.GzipFile(fileobj=BytesIO(bgzf._bgzf_eof))
+ try:
+ data = h.read()
+ h.close()
+ assert not data, "Should be zero length, not %i" % len(data)
+ return False
+ except TypeError, err:
+ #TypeError: integer argument expected, got 'tuple'
+ return True
+
+if _have_bug17666():
+ from Bio import MissingPythonDependencyError
+ raise MissingPythonDependencyError("Your Python has a broken gzip library, see "
+ "http://bugs.python.org/issue17666 for details")
+
class BgzfTests(unittest.TestCase):
def setUp(self):

0 comments on commit 975f5c4

Please sign in to comment.