You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a continuation of #1515 which allowed us to enforce the flake8 style checks E127 and E128 on Bio (and this was already enforced on BioSQL, Scripts and Doc/examples).
I'm marking this as a good first issue for a potential new contributor - it does not require any prior knowledge of Biopython's internals, although familiarity with Python syntax is needed.
It looks like PEP 257 recommends that single line docstrings look like this:
"""Test repair of a single ambiguous position in a genome."""
rather than:
"""Test repair of a single ambiguous position in a genome."""
Should I fix these along with this issue, or leave this for a separate pull request?
Also, there are a few examples of tests that look like this
deftest_single_repair(self):
"""Test repair of a single ambiguous position in a genome. """repairer=AmbiguousRepair(self.ambig_info, 2)
forrepair_attemptinrange(5):
new_org=repairer.repair(self.organism)
new_genome_seq=new_org.genome.toseq()
assertnew_genome_seq.count("*") ==2, \
"Did not repair genome, got %s"%str(new_genome_seq)
I can fix the E127 error that is raised by the assert line by changing it to a single indent after the newline, but that may not be the best solution. If I'm reading through the unittest documentation correctly, would it be appropriate to change that assert statement to this?
self.assertEqual(new_genome_seq.count("*"), 2,
"Did not repair genome, got %s"%str(new_genome_seq))
I figure I can either I can change the assert statements to the unittest assert*() methods or I can just address the the E127 / E128 errors. My preference is to change all of the assert statements to the assert*() methods now as I'm digging through this, but if that makes sense as multiple pull requests I can do that too.
From the unittest documentation: "To make migrating existing test suites easier, unittest supports tests raising AssertionError to indicate test failure. However, it is recommended that you use the explicit TestCase.fail*() and TestCase.assert*() methods instead, as future versions of unittest may treat AssertionError differently."
Yes, PEP8 does recommend that for the one-line docstrings, and we enforce this on Bio/ etc already. A second pull request fixing that on Tests/ and updating Tests/.flake8 to enforce it would be great.
Also yes, where the test files are using the unittest framework we should be using self.assertTrue(statement, message) or similar over assert statement, message - doing that as part of the E127 pull request makes perfect sense to me. This syntax with brackets is also more elegant for multi-line statements.
And yes, try to use the more specific self.assert* methods as appropriate - almost all of them are available on Python 2.7 onwards.
Activity
nimne commentedon Aug 26, 2018
I'll take a crack at this. It'll be a good chance to get familiar with the testing code!
nimne commentedon Aug 27, 2018
Couple questions as I'm working through this.
It looks like PEP 257 recommends that single line docstrings look like this:
"""Test repair of a single ambiguous position in a genome."""rather than:
Should I fix these along with this issue, or leave this for a separate pull request?
Also, there are a few examples of tests that look like this
I can fix the E127 error that is raised by the assert line by changing it to a single indent after the newline, but that may not be the best solution. If I'm reading through the unittest documentation correctly, would it be appropriate to change that assert statement to this?
I figure I can either I can change the
assertstatements to the unittestassert*()methods or I can just address the the E127 / E128 errors. My preference is to change all of theassertstatements to theassert*()methods now as I'm digging through this, but if that makes sense as multiple pull requests I can do that too.From the unittest documentation: "To make migrating existing test suites easier,
unittestsupports tests raisingAssertionErrorto indicate test failure. However, it is recommended that you use the explicitTestCase.fail*()andTestCase.assert*()methods instead, as future versions ofunittestmay treatAssertionErrordifferently."peterjc commentedon Aug 28, 2018
Yes, PEP8 does recommend that for the one-line docstrings, and we enforce this on
Bio/etc already. A second pull request fixing that onTests/and updatingTests/.flake8to enforce it would be great.peterjc commentedon Aug 28, 2018
Also yes, where the test files are using the
unittestframework we should be usingself.assertTrue(statement, message)or similar overassert statement, message- doing that as part of the E127 pull request makes perfect sense to me. This syntax with brackets is also more elegant for multi-line statements.And yes, try to use the more specific
self.assert*methods as appropriate - almost all of them are available on Python 2.7 onwards.peterjc commentedon Sep 4, 2018
Closed via #1780, thank you @nimne!