Repository navigation
Closed
Labels
Description
See #2700 for background, cross reference #2833 (comment) e.g.
$ grep assertTrue *.py | grep "=="
common_BioSQL.py: self.assertTrue(self.db.load(seqiter) == 1)
test_ClustalOmega_tool.py: self.assertTrue(error.strip() == "" or
...
and:
$ grep assertFalse *.py | grep "!="
test_Restriction.py: self.assertFalse(Acc65I != Asp718I)
Those should use assertEqual, while:
$ grep assertTrue *.py | grep "!="
test_SearchIO_model.py: self.assertTrue(hit11.id != "alt1")
test_SearchIO_model.py: self.assertTrue(hit11.id != "alt11")
test_SearchIO_model.py: self.assertTrue(hit11.id != "alt1")
and:
$ grep assertFalse *.py | grep "=="
test_PDB.py: self.assertFalse(struct[0] == struct[1])
test_PDB.py: self.assertFalse(struct[0] == []) # __eq__ diff. types
test_PDB.py: self.assertFalse(struct == model)
test_PDB.py: self.assertFalse(res1 == res2)
test_PDB_StructureAlignment.py: self.assertFalse(al.map12 == al.map21)
test_Restriction.py: self.assertFalse(FormattedSeq(Seq("GATC")) ==
test_Restriction.py: self.assertFalse(FormattedSeq(Seq("TAGC")) == Seq("TAGC"))
test_Restriction.py: self.assertFalse(Acc65I == Asp718I)
Those shoud use self.assertNotEqual
Not this cleanup work is not specific to dropping Python 3:
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertEqual
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertNotEqual
However, some of the older usage probably did require at least Python 2.7:
Activity
peterjc commentedon Apr 11, 2020
See also #2700 (comment) where the
A500check fromflake8-assertiveshould catch more than my quick grep searches.trkohler commentedon Apr 30, 2020
Hi!
Can I work on this? I'd like to help!
It might be my first open-source issue so if it requires any special knowledge, please let me know
peterjc commentedon Apr 30, 2020
@trkohler Welcome! You should be fine with basic Python knowledge (very few of the Biopython objects do anything strange with self-defined equality rules). I suggest you pick a related batch of files, say which ones here (to reduce the chance of someone else working on the same thing), and start working. Thank you.
peterjc commentedon May 1, 2020
To clarify, probably best don't touch
test_Restriction.pywhich was done in #2833.trkohler commentedon May 1, 2020
may I consider this one as done? Or did I miss something again? I'm sorry for my inattention, I was too excited by the fact I can do something for such a project.
peterjc commentedon May 8, 2020
Using the
flake8-assertiveplugin, code A500 covers more than just equal and not equal, but:So assuming
test_Restriction.pyis all fine via #2833, that leaves a few cases intest_Pathway.py,test_PDB.py, andcommon_BioSQL.pyremaining.trkohler commentedon May 8, 2020
cool! It means I still have some easy things to do! 👯♀️
trkohler commentedon May 8, 2020
Can I run somehow CI/CD checks in draft PR once again? I added commit to fix errors, but can't test locally - my machine is too weak, it lacks memory and tests run too long.
peterjc commentedon May 8, 2020
Since you are only editing the tests, you only need to run that one test - e.g.
python run_tests.py test_Pathway.pywhich should be quick.Or I guess you must change the GitHub pull request from draft to normal? The draft thing is quite new so we don't yet have that much experience with it.
Small fixes with assertion methods in test files (#2869)
[-]Use assertEqual and assertNotEqual unittest methods[/-][+]Use assertEqual etc unittest methods[/+]16 remaining items
sgalpha01 commentedon Sep 11, 2020
Do this issue still need some work?
peterjc commentedon Sep 11, 2020
Yes, there are still a few files to be fixed - using flake8-assertive v1.2.1
(As noted above, best avoid
test_Restriction.pydue to non standard object sorting behaviour)sgalpha01 commentedon Sep 11, 2020
Okay, I will try my best. This is going to be my first open-source issue
peterjc commentedon Sep 11, 2020
Good job @sgalpha01 !
If you want to try
test_Restriction.pyas well, you'd be most welcome. However, it may much more care since the comparison methods defined are a little strange --__ne__is not the inverse of__eq__for a start:https://github.com/biopython/biopython/blob/master/Bio/Restriction/Restriction.py#L378
https://github.com/biopython/biopython/blob/master/Bio/Restriction/Restriction.py#L388
sgalpha01 commentedon Sep 12, 2020
flake8 --isolated --select A500 . >> ../TODO.txtgives the following text file:So, there are two files which needs attention.
I started with
test_NCBI_qblast.py, and made the required changes.But, I am not able to commit because of the following error:
I am not sure what's the problem. At first, I thought it was editor specific. So, I tried Vim, but no luck.
Update: I just needed to apply black.
changed assertion styling for test_NCBI_qblast.py (#3273)
lacrosse91 commentedon Sep 14, 2020
Hello!
Do this issue still need some work?
I'd like to help!
peterjc commentedon Sep 14, 2020
Just
test_Restriction.pyleft, which is somewhat unusual so I've taken off the "good first issue" tag:If @sgalpha01 isn't working on it, you could give it a try. It might go smoothly - just don't change the condition (e.g. don't assume
a < bis the same asb > a, ornot(a == b)is the same asa != bwith these objects).lacrosse91 commentedon Sep 14, 2020
Thanks for reply.
I'll try it.
sgalpha01 commentedon Sep 14, 2020
@lacrosse91 , hey you can work on this if you want.
lacrosse91 commentedon Sep 14, 2020
@sgalpha01 , Thank you!
I'm going to work on this.
changed assertion styling for test_Restriction.py (#3276)
peterjc commentedon Sep 15, 2020
That's all done now:
Thank you everyone - a big team effort.