Skip to content

changed assertion styling for test_Restriction.py - #3276

Merged
peterjc merged 2 commits into
biopython:masterfrom
lacrosse91:unittest-styling-fixes
Sep 15, 2020
Merged

peterjc merged 2 commits into
biopython:masterfrom
lacrosse91:unittest-styling-fixes

Conversation

@lacrosse91

Copy link
Copy Markdown
Contributor
  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file, have run pre-commit locally,
    and understand that AppVeyor and TravisCI will be used to confirm the Biopython unit
    tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

This pull request addresses issue #2835

@codecov

codecov Bot commented Sep 14, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #3276 into master will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3276      +/-   ##
==========================================
- Coverage   83.93%   83.93%   -0.01%     
==========================================
  Files         317      317              
  Lines       51556    51584      +28     
==========================================
+ Hits        43275    43297      +22     
- Misses       8281     8287       +6     
Impacted Files Coverage Δ
Bio/PDB/Atom.py 89.22% <0.00%> (-0.69%) ⬇️
Bio/PDB/Entity.py 92.24% <0.00%> (-0.37%) ⬇️
Bio/PDB/Residue.py 82.22% <0.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 05ef881...7f4aed9. Read the comment docs.

Comment thread Tests/test_Restriction.py
self.assertFalse(Acc65I == Asp718I)
self.assertEqual(Acc65I == Asp718I, False)
# self.assertNotEqual(Acc65I, Asp718I) it doesn't work as expected
self.assertFalse(Acc65I != Asp718I)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the line above look like the problem cases, and I think that neither self.assertEqual nor self.assertNotEqual will work here? I've not tried that, but I did look at the source code:

https://github.com/python/cpython/blob/master/Lib/unittest/case.py

However, I think the originals using self.assertFalse are actually clearer than self.assertEqual(..., False).

I'm going to ask for a second opinion, but I would be inclined to leave these two lines as they are. We could add the special comment # noqa: A500 to tell flake8 to ignore the warning from flake8-assertive (if installed).

@MarkusPiotrowski could you comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review.
Should I wait for his response?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait for now - the second opinion might be different.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bio.Restriction overwrites the == and != comparisons for some special meaning regarding neo- and isoschizomers. So what is actually tested here are the comparison operators and thus I think that the original tests are indeed clearer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Markus.

@lacrosse91 could you revert those two lines (and optionally add the # noqa: A500 comment - which should make flake8-assertive happy and document this use of assertTrue is deliberate).

@peterjc peterjc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments about the Acc65I == Asp718I and Acc65I != Asp718I tests.

@lacrosse91

Copy link
Copy Markdown
Contributor Author

@peterjc and @MarkusPiotrowski
Thank you for advice.
please review the changes.

@peterjc
peterjc merged commit ec414fb into biopython:master Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants