1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Test for Blast records."""
import unittest
from Bio.Blast.Record import HSP
class TestHsp(unittest.TestCase):
def test_str(self):
# Test empty instance
self.assertEqual(
str(HSP()),
"Score <unknown> (<unknown> bits), expectation <unknown>, alignment length <unknown>",
)
# Test instance with non-default attributes
hsp = HSP()
hsp.score = 1.0
hsp.bits = 2.0
hsp.expect = 3.0
hsp.align_length = 4
# Ignore trailing whitespace in output
self.assertEqual(
"\n".join(l.strip() for l in str(hsp).split("\n")),
"""Score 1 (2 bits), expectation 3.0e+00, alignment length 4
Query: None None
Sbjct: None None""",
)
if __name__ == "__main__":
runner = unittest.TextTestRunner(verbosity=2)
unittest.main(testRunner=runner)
|