diff --git a/Tests/run_tests.py b/Tests/run_tests.py index 5b52b8650bc..16f8d7d6d0c 100644 --- a/Tests/run_tests.py +++ b/Tests/run_tests.py @@ -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,