Skip to content

Commit

Permalink
Can't import anything from Bio in run_tests.py
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjc committed May 15, 2013
1 parent 6505019 commit 79d10c5
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions Tests/run_tests.py
Expand Up @@ -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,
Expand Down

0 comments on commit 79d10c5

Please sign in to comment.