Skip to content

Commit

Permalink
Fix string concatenation style in Tests/
Browse files Browse the repository at this point in the history
Some of these are recent regressions introduced by black
psf/black#26

Others are long standing pre-existing style issues.
  • Loading branch information
peterjc committed Nov 29, 2019
1 parent ade342f commit 1b2619f
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 94 deletions.
6 changes: 4 additions & 2 deletions Tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ def _have_bug17666():
return False
import gzip
# 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"
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_encode(bgzf_eof)[0]
Expand Down
4 changes: 2 additions & 2 deletions Tests/search_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def compare_search_obj(obj_a, obj_b):
# compare objects recursively if it's not an HSPFragment
if not isinstance(obj_a, SearchIO.HSPFragment):
# check the number of hits contained
assert len(obj_a) == len(obj_b), "length: %i vs %i for " \
"%r vs %r" % (len(obj_a), len(obj_b), obj_a, obj_b)
assert len(obj_a) == len(obj_b), ("length: %i vs %i for %r vs %r"
% (len(obj_a), len(obj_b), obj_a, obj_b))

for item_a, item_b in zip(obj_a, obj_b):
assert compare_search_obj(item_a, item_b)
Expand Down
5 changes: 2 additions & 3 deletions Tests/seq_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,8 @@ def compare_record(old, new):
old_comment = old_comment.replace("\n", " ").replace(" ", " ")
new_comment = new_comment.replace("\n", " ").replace(" ", " ")
assert old_comment == new_comment, \
"Comment annotation changed by load/retrieve\n" \
"Was:%s\nNow:%s" \
% (repr(old_comment), repr(new_comment))
("Comment annotation changed by load/retrieve\n"
"Was:%s\nNow:%s" % (repr(old_comment), repr(new_comment)))
elif key in ["taxonomy", "organism", "source"]:
# If there is a taxon id recorded, these fields get overwritten
# by data from the taxon/taxon_name tables. There is no
Expand Down
50 changes: 25 additions & 25 deletions Tests/test_AlignIO_FastaIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,24 @@ def test_output001(self):
self.assertEqual(len(alignments[2]), 2)
self.assertEqual(alignments[2].get_alignment_length(), 38)
self.assertEqual(
alignments[2][0].seq, "MKKDKKYQIEAIKNKDKTLFIVYATDI" "YSPSEFFSKIE"
alignments[2][0].seq, "MKKDKKYQIEAIKNKDKTLFIVYATDIYSPSEFFSKIE"
)
self.assertEqual(alignments[2][0].id, "gi|10955264|ref|NP_052605.1|")
self.assertEqual(alignments[2][0].annotations["original_length"], 126)
self.assertEqual(
alignments[2][1].seq, "IKKDLGVSFLKLKNREKTLIVDALKKK" "YPVAELLSVLQ"
alignments[2][1].seq, "IKKDLGVSFLKLKNREKTLIVDALKKKYPVAELLSVLQ"
)
self.assertEqual(alignments[2][1].id, "gi|152973462|ref|YP_001338513.1|")
self.assertEqual(alignments[2][1].annotations["original_length"], 101)
self.assertEqual(len(alignments[3]), 2)
self.assertEqual(alignments[3].get_alignment_length(), 43)
self.assertEqual(
alignments[3][0].seq, "SELHSKLPKSIDKIHEDIKKQLSC-SL" "IMKKIDVEMEDYSTYC"
alignments[3][0].seq, "SELHSKLPKSIDKIHEDIKKQLSC-SLIMKKIDVEMEDYSTYC"
)
self.assertEqual(alignments[3][0].id, "gi|10955265|ref|NP_052606.1|")
self.assertEqual(alignments[3][0].annotations["original_length"], 346)
self.assertEqual(
alignments[3][1].seq, "SRINSDVARRIPGIHRDPKDRLSSLKQ" "VEEALDMLISSHGEYC"
alignments[3][1].seq, "SRINSDVARRIPGIHRDPKDRLSSLKQVEEALDMLISSHGEYC"
)
self.assertEqual(alignments[3][1].id, "gi|152973545|ref|YP_001338596.1|")
self.assertEqual(alignments[3][1].annotations["original_length"], 242)
Expand Down Expand Up @@ -110,13 +110,13 @@ def test_output002(self):
self.assertEqual(alignments[1].get_alignment_length(), 53)
self.assertEqual(
alignments[1][0].seq,
"EIRKRAAECGKTVSGFLRAAA-L" "GKKV----NSLTDDRVLKEVMRL" "GALQKKL",
"EIRKRAAECGKTVSGFLRAAA-LGKKV----NSLTDDRVLKEVMRLGALQKKL",
)
self.assertEqual(alignments[1][0].id, "gi|10955263|ref|NP_052604.1|")
self.assertEqual(alignments[1][0].annotations["original_length"], 107)
self.assertEqual(
alignments[1][1].seq,
"EIKPRGTSKGEAIAAFMQEAPFI" "GRTPVFLGDDLTDESGFAVVNRL" "GGMSVKI",
"EIKPRGTSKGEAIAAFMQEAPFIGRTPVFLGDDLTDESGFAVVNRLGGMSVKI",
)
self.assertEqual(alignments[1][1].id, "gi|15831859|ref|NP_310632.1|")
self.assertEqual(alignments[1][1].annotations["original_length"], 266)
Expand Down Expand Up @@ -165,13 +165,13 @@ def test_output002(self):
self.assertEqual(alignments[4].get_alignment_length(), 63)
self.assertEqual(
alignments[4][0].seq,
"VDIKK-ETIESELHSKLPKSIDK" "IHEDIKKQLSCSLI--MKKID-V" "EMEDYSTYCFSALRAIE",
"VDIKK-ETIESELHSKLPKSIDKIHEDIKKQLSCSLI--MKKID-VEMEDYSTYCFSALRAIE",
)
self.assertEqual(alignments[4][0].id, "gi|10955265|ref|NP_052606.1|")
self.assertEqual(alignments[4][0].annotations["original_length"], 346)
self.assertEqual(
alignments[4][1].seq,
"IDPKKIEQIARQVHESMPKGIRE" "FGEDVEKKIRQTLQAQLTRLDLV" "SREEFDVQTQVLLRTRE",
"IDPKKIEQIARQVHESMPKGIREFGEDVEKKIRQTLQAQLTRLDLVSREEFDVQTQVLLRTRE",
)
self.assertEqual(alignments[4][1].id, "gi|38704138|ref|NP_311957.2|")
self.assertEqual(alignments[4][1].annotations["original_length"], 111)
Expand Down Expand Up @@ -212,13 +212,13 @@ def test_output003(self):
self.assertEqual(alignments[0].get_alignment_length(), 55)
self.assertEqual(
alignments[0][0].seq,
"ISISNNKDQYEELQKEQGERDLK" "TVDQLVRIAAAGGGLRLSASTKT" "VDQLVRIAA",
"ISISNNKDQYEELQKEQGERDLKTVDQLVRIAAAGGGLRLSASTKTVDQLVRIAA",
)
self.assertEqual(alignments[0][0].id, "gi|152973837|ref|YP_001338874.1|")
self.assertEqual(alignments[0][0].annotations["original_length"], 183)
self.assertEqual(
alignments[0][1].seq,
"VRLTAEEDQ--EIRKRAAECG-K" "TVSGFLRAAALGKKVNSLTDDR" "VLKEVMRLGA",
"VRLTAEEDQ--EIRKRAAECG-KTVSGFLRAAALGKKVNSLTDDRVLKEVMRLGA",
)
self.assertEqual(alignments[0][1].id, "gi|10955263|ref|NP_052604.1|")
self.assertEqual(alignments[0][1].annotations["original_length"], 107)
Expand All @@ -234,13 +234,13 @@ def test_output003(self):
self.assertEqual(alignments[2].get_alignment_length(), 63)
self.assertEqual(
alignments[2][0].seq,
"VFGSFEQPKGEHLSGQVSEQ--R" "DTAFADQNEQVIRHLKQEIEHLN" "TLLLSKDSHIDSLKQAM",
"VFGSFEQPKGEHLSGQVSEQ--RDTAFADQNEQVIRHLKQEIEHLNTLLLSKDSHIDSLKQAM",
)
self.assertEqual(alignments[2][0].id, "gi|152973841|ref|YP_001338878.1|")
self.assertEqual(alignments[2][0].annotations["original_length"], 133)
self.assertEqual(
alignments[2][1].seq,
"VYTSFN---GEKFSSYTLNKVTK" "TDEYNDLSELSASFFKKNFDKIN" "VNLLSKATSF-ALKKGI",
"VYTSFN---GEKFSSYTLNKVTKTDEYNDLSELSASFFKKNFDKINVNLLSKATSF-ALKKGI",
)
self.assertEqual(alignments[2][1].id, "gi|10955264|ref|NP_052605.1|")
self.assertEqual(alignments[2][1].annotations["original_length"], 126)
Expand Down Expand Up @@ -383,24 +383,24 @@ def test_output007(self):
self.assertEqual(len(alignments[2]), 2)
self.assertEqual(alignments[2].get_alignment_length(), 45)
self.assertEqual(
alignments[2][0].seq, "EIRKRAAECGKTVSGFLRAAA--" "---LGKKVNSLTDDRVLKEVMR"
alignments[2][0].seq, "EIRKRAAECGKTVSGFLRAAA-----LGKKVNSLTDDRVLKEVMR"
)
self.assertEqual(alignments[2][0].id, "gi|10955263|ref|NP_052604.1|")
self.assertEqual(alignments[2][0].annotations["original_length"], 107)
self.assertEqual(
alignments[2][1].seq, "ELVKLIADMGISVRALLRKNVEP" "YEELGLEEDKFTDDQLIDFMLQ"
alignments[2][1].seq, "ELVKLIADMGISVRALLRKNVEPYEELGLEEDKFTDDQLIDFMLQ"
)
self.assertEqual(alignments[2][1].id, "gi|152973480|ref|YP_001338531.1|")
self.assertEqual(alignments[2][1].annotations["original_length"], 141)
self.assertEqual(len(alignments[3]), 2)
self.assertEqual(alignments[3].get_alignment_length(), 38)
self.assertEqual(
alignments[3][0].seq, "MKKDKKYQIEAIKNKDKTLFIVY" "ATDIYSPSEFFSKIE"
alignments[3][0].seq, "MKKDKKYQIEAIKNKDKTLFIVYATDIYSPSEFFSKIE"
)
self.assertEqual(alignments[3][0].id, "gi|10955264|ref|NP_052605.1|")
self.assertEqual(alignments[3][0].annotations["original_length"], 126)
self.assertEqual(
alignments[3][1].seq, "IKKDLGVSFLKLKNREKTLIVDA" "LKKKYPVAELLSVLQ"
alignments[3][1].seq, "IKKDLGVSFLKLKNREKTLIVDALKKKYPVAELLSVLQ"
)
self.assertEqual(alignments[3][1].id, "gi|152973462|ref|YP_001338513.1|")
self.assertEqual(alignments[3][1].annotations["original_length"], 101)
Expand All @@ -415,32 +415,32 @@ def test_output007(self):
self.assertEqual(len(alignments[5]), 2)
self.assertEqual(alignments[5].get_alignment_length(), 40)
self.assertEqual(
alignments[5][0].seq, "DKTLFIVYATDIYSPSE-FFSKI" "ESDLKKKKSKGD-VFFD"
alignments[5][0].seq, "DKTLFIVYATDIYSPSE-FFSKIESDLKKKKSKGD-VFFD"
)
self.assertEqual(alignments[5][0].id, "gi|10955264|ref|NP_052605.1|")
self.assertEqual(alignments[5][0].annotations["original_length"], 126)
self.assertEqual(
alignments[5][1].seq, "ESVVFILMAGFAMSVCYLFFSVL" "EKVINARKSKDESIYHD"
alignments[5][1].seq, "ESVVFILMAGFAMSVCYLFFSVLEKVINARKSKDESIYHD"
)
self.assertEqual(alignments[5][1].id, "gi|152973581|ref|YP_001338632.1|")
self.assertEqual(alignments[5][1].annotations["original_length"], 84)
self.assertEqual(len(alignments[6]), 2)
self.assertEqual(alignments[6].get_alignment_length(), 30)
self.assertEqual(alignments[6][0].seq, "ASFFKKNFDKINVNLLSKATSFA" "LKKGIPI")
self.assertEqual(alignments[6][0].seq, "ASFFKKNFDKINVNLLSKATSFALKKGIPI")
self.assertEqual(alignments[6][0].id, "gi|10955264|ref|NP_052605.1|")
self.assertEqual(alignments[6][0].annotations["original_length"], 126)
self.assertEqual(alignments[6][1].seq, "ASFSKEEQDKVAVDKVAADVAWQ" "ERMNKPV")
self.assertEqual(alignments[6][1].seq, "ASFSKEEQDKVAVDKVAADVAWQERMNKPV")
self.assertEqual(alignments[6][1].id, "gi|152973536|ref|YP_001338587.1|")
self.assertEqual(alignments[6][1].annotations["original_length"], 84)
self.assertEqual(len(alignments[7]), 2)
self.assertEqual(alignments[7].get_alignment_length(), 43)
self.assertEqual(
alignments[7][0].seq, "SELHSKLPKSIDKIHEDIKKQLS" "C-SLIMKKIDVEMEDYSTYC"
alignments[7][0].seq, "SELHSKLPKSIDKIHEDIKKQLSC-SLIMKKIDVEMEDYSTYC"
)
self.assertEqual(alignments[7][0].id, "gi|10955265|ref|NP_052606.1|")
self.assertEqual(alignments[7][0].annotations["original_length"], 346)
self.assertEqual(
alignments[7][1].seq, "SRINSDVARRIPGIHRDPKDRLS" "SLKQVEEALDMLISSHGEYC"
alignments[7][1].seq, "SRINSDVARRIPGIHRDPKDRLSSLKQVEEALDMLISSHGEYC"
)
self.assertEqual(alignments[7][1].id, "gi|152973545|ref|YP_001338596.1|")
self.assertEqual(alignments[7][1].annotations["original_length"], 242)
Expand Down Expand Up @@ -807,10 +807,10 @@ def test_output008(self):
self.assertEqual(alignments[9][1].annotations["original_length"], 4301)
self.assertEqual(len(alignments[10]), 2)
self.assertEqual(alignments[10].get_alignment_length(), 30)
self.assertEqual(alignments[10][0].seq, "IMMNKQFRNCMLTTICCGKNPL" "GDDEASAT")
self.assertEqual(alignments[10][0].seq, "IMMNKQFRNCMLTTICCGKNPLGDDEASAT")
self.assertEqual(alignments[10][0].id, "sp|P08100|OPSD_HUMAN")
self.assertEqual(alignments[10][0].annotations["original_length"], 348)
self.assertEqual(alignments[10][1].seq, "MLLAFQFRNCMLTTLCCGKNPL" "GDDEASTT")
self.assertEqual(alignments[10][1].seq, "MLLAFQFRNCMLTTLCCGKNPLGDDEASTT")
self.assertEqual(alignments[10][1].id, "gi|283855845|gb|GQ290303.1|")
self.assertEqual(alignments[10][1].annotations["original_length"], 4301)
self.assertEqual(len(alignments[11]), 2)
Expand All @@ -819,7 +819,7 @@ def test_output008(self):
self.assertEqual(alignments[11][0].id, "sp|P08100|OPSD_HUMAN")
self.assertEqual(alignments[11][0].annotations["original_length"], 348)
self.assertEqual(
alignments[11][1].seq, "SQQIRNATTMMMTMRVTSFSAFW" "VVADSCCW"
alignments[11][1].seq, "SQQIRNATTMMMTMRVTSFSAFWVVADSCCW"
)
self.assertEqual(alignments[11][1].id, "gi|283855822|gb|GQ290312.1|")
self.assertEqual(alignments[11][1].annotations["original_length"], 983)
Expand Down
16 changes: 8 additions & 8 deletions Tests/test_GenBank.py
Original file line number Diff line number Diff line change
Expand Up @@ -6354,7 +6354,7 @@ def test_001_genbank_bad_origin_wrapping_location(self):
with self.assertRaises(BiopythonParserWarning) as cm:
record = SeqIO.read(path, "genbank")
self.assertIn(
"It appears that '6801..100' is a feature " "that spans the origin",
"It appears that '6801..100' is a feature that spans the origin",
str(cm.exception),
)

Expand Down Expand Up @@ -6385,19 +6385,19 @@ def test_compound_complex_origin_wrap(self):
self.assertIsInstance(record.features[3].location, CompoundLocation)
self.assertEqual(
str(record.features[3].location),
"join{[<5399:5600](+), [5699:6100](+), " "[6800:7000](+), [0:100](+)}",
"join{[<5399:5600](+), [5699:6100](+), [6800:7000](+), [0:100](+)}",
)

self.assertIsInstance(record.features[4].location, CompoundLocation)
self.assertEqual(
str(record.features[4].location),
"join{[5399:5600](+), [5699:6100](+), " "[<6800:7000](+), [0:100](+)}",
"join{[5399:5600](+), [5699:6100](+), [<6800:7000](+), [0:100](+)}",
)

self.assertIsInstance(record.features[5].location, CompoundLocation)
self.assertEqual(
str(record.features[5].location),
"join{[5399:5600](+), [5699:6100](+), " "[0:100](-), [<6800:7000](-)}",
"join{[5399:5600](+), [5699:6100](+), [0:100](-), [<6800:7000](-)}",
)

def test_implicit_orign_wrap_extract_and_translate(self):
Expand All @@ -6410,11 +6410,11 @@ def test_implicit_orign_wrap_extract_and_translate(self):
seq_features = seq_record.features
self.assertEqual(
str(seq_features[1].extract(seq_record).seq.lower()),
"atgccctataaaacccagggctgccttggaaaaggcgcaacccc" "aaccccctcgagccgcggcatataa",
"atgccctataaaacccagggctgccttggaaaaggcgcaaccccaaccccctcgagccgcggcatataa",
)
self.assertEqual(
str(seq_features[2].extract(seq_record).seq.lower()),
"atgccgcggctcgagggggttggggttgcgccttttccaaggca" "gccctgggttttatag",
"atgccgcggctcgagggggttggggttgcgccttttccaaggcagccctgggttttatag",
)
self.assertEqual(
str(seq_features[1].extract(seq_record).seq.translate()),
Expand Down Expand Up @@ -7231,7 +7231,7 @@ def test_genbank_interaction(self):
self.assertEqual(l_r[0].id, "NC_000932.1")
self.assertEqual(l_r[0].name, "NC_000932")
self.assertEqual(
l_r[0].description, "Arabidopsis thaliana chloroplast, " "complete genome"
l_r[0].description, "Arabidopsis thaliana chloroplast, complete genome"
)
self.assertEqual(len(l_r[0].features), 0)

Expand All @@ -7242,7 +7242,7 @@ def test_genbank_interaction(self):
self.assertEqual(l_r[0].id, "NC_000932.1")
self.assertEqual(l_r[0].name, "NC_000932")
self.assertEqual(
l_r[0].description, "Arabidopsis thaliana chloroplast, " "complete genome"
l_r[0].description, "Arabidopsis thaliana chloroplast, complete genome"
)
self.assertEqual(len(l_r[0].features), 259)

Expand Down
42 changes: 24 additions & 18 deletions Tests/test_GenomeDiagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,14 @@ def tearDown(self):

def test_str(self):
"""Test diagram's info as string."""
expected = "\n<<class 'Bio.Graphics.GenomeDiagram._Diagram.Diagram'>: Test Diagram>" \
"\n1 tracks" \
"\nTrack 1: " \
"\n<<class 'Bio.Graphics.GenomeDiagram._Track.Track'>: CDS Features>" \
"\n0 sets" \
"\n"
expected = (
"\n<<class 'Bio.Graphics.GenomeDiagram._Diagram.Diagram'>: Test Diagram>"
"\n1 tracks"
"\nTrack 1: "
"\n<<class 'Bio.Graphics.GenomeDiagram._Track.Track'>: CDS Features>"
"\n0 sets"
"\n"
)
self.assertEqual(expected, str(self.gdd))

def test_add_track(self):
Expand Down Expand Up @@ -679,23 +681,27 @@ def test_get_tracks(self):
def test_move_track(self):
"""Move a track."""
self.gdd.move_track(1, 2)
expected = "\n<<class 'Bio.Graphics.GenomeDiagram._Diagram.Diagram'>: Test Diagram>" \
"\n1 tracks" \
"\nTrack 2: " \
"\n<<class 'Bio.Graphics.GenomeDiagram._Track.Track'>: CDS Features>" \
"\n0 sets" \
"\n"
expected = (
"\n<<class 'Bio.Graphics.GenomeDiagram._Diagram.Diagram'>: Test Diagram>"
"\n1 tracks"
"\nTrack 2: "
"\n<<class 'Bio.Graphics.GenomeDiagram._Track.Track'>: CDS Features>"
"\n0 sets"
"\n"
)
self.assertEqual(expected, str(self.gdd))

def test_renumber(self):
"""Test renumbering tracks."""
self.gdd.renumber_tracks(0)
expected = "\n<<class 'Bio.Graphics.GenomeDiagram._Diagram.Diagram'>: Test Diagram>" \
"\n1 tracks" \
"\nTrack 0: " \
"\n<<class 'Bio.Graphics.GenomeDiagram._Track.Track'>: CDS Features>" \
"\n0 sets" \
"\n"
expected = (
"\n<<class 'Bio.Graphics.GenomeDiagram._Diagram.Diagram'>: Test Diagram>"
"\n1 tracks"
"\nTrack 0: "
"\n<<class 'Bio.Graphics.GenomeDiagram._Track.Track'>: CDS Features>"
"\n0 sets"
"\n"
)
self.assertEqual(expected, str(self.gdd))

def test_write_arguments(self):
Expand Down
6 changes: 4 additions & 2 deletions Tests/test_Nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,10 @@ def test_TreeTest1(self):

def test_TreeTest2(self):
"""Handle text labels on internal nodes."""
ts1b = "(Cephalotaxus:125.000000,(Taxus:100.000000,Torreya:100.000000)" \
"TT1:25.000000)Taxaceae:90.000000;"
ts1b = (
"(Cephalotaxus:125.000000,(Taxus:100.000000,Torreya:100.000000)"
"TT1:25.000000)Taxaceae:90.000000;"
)
tree = Trees.Tree(ts1b)
self.assertEqual(self._get_flat_nodes(tree), [("Taxaceae", 90.0, None, None),
("Cephalotaxus", 125.0, None, None),
Expand Down
Loading

0 comments on commit 1b2619f

Please sign in to comment.