Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Can't import anything from Bio in run_tests.py

  • Loading branch information...
commit 79d10c5fb027304503a9cbf2d9c844f5cef9dfde 1 parent 6505019
Peter Cock peterjc authored
Showing with 29 additions and 3 deletions.
  1. +29 −3 Tests/run_tests.py
32 Tests/run_tests.py
View
@@ -140,9 +140,35 @@ def is_numpy():
DOCTEST_MODULES.remove("Bio.Seq")
#Skip Bio.bgzf doctest for broken gzip, see http://bugs.python.org/issue17666
-try:
- from test_bgzf import _have_bug17666
-except MissingPythonDependencyError:
+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.
+ """
+ import gzip
+ try:
+ from io import BytesIO
+ except ImportError:
+ #Python 2.5 fall back
+ from StringIO import StringIO as BytesIO
+ #Would like to use byte literal here:
+ bgzf_eof = "\x1f\x8b\x08\x04\x00\x00\x00\x00\x00\xff\x06\x00BC" + \
+ "\x02\x00\x1b\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ if sys.version_info[0] >= 3:
+ import codecs
+ bgzf_eof = codecs.latin_1_decode(bgzf_eof)[0]
+ h = gzip.GzipFile(fileobj=BytesIO(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'
+ h.close()
+ return True
+if _have_bug17666():
DOCTEST_MODULES.remove("Bio.bgzf")
#HACK: Since Python2.5 under Windows have slightly different str(float) output,
Please sign in to comment.
Something went wrong with that request. Please try again.