Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed test functions in test_lowest_common_ancestors #6110

Merged
merged 4 commits into from
Oct 31, 2022

Conversation

tindi-plus
Copy link
Contributor

@tindi-plus tindi-plus commented Oct 20, 2022

This pull request will fix issue #5863.
The method names of the test classes have been modified to depict what the method is testing.
The modifications are for networkx/algorithms/tests/test_lowest_common_ancestors.py

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Thanks @tindi-plus this is the right general idea, though it'd be nice to preserve the function that is being tested in the test name (or at least something similar - I arbitrarily suggested abbreviating "lca"): see the suggestions below.

Of course, in this case the tests are implemented as methods under the TestTreeLCA class, so repeating the function name in the test is arguably a bit redundant.

@@ -51,38 +51,38 @@ def assert_has_same_pairs(d1, d2):
for (a, b) in ((min(pair), max(pair)) for pair in chain(d1, d2)):
assert get_pair(d1, a, b) == get_pair(d2, a, b)

def test_tree_all_pairs_lowest_common_ancestor1(self):
def test_specifying_root_optional_in_lca(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def test_specifying_root_optional_in_lca(self):
def test_tree_all_pairs_lca_defaults(self):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have started work on the changes and a quick question:
Since the test method is actually testing that adding a starting root produces the same result as not adding a root, won't this be more descriptive?

Suggested change
def test_specifying_root_optional_in_lca(self):
def test_tree_all_pairs_lca_root_is_optional(self):

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably call it lca_default_root, but honestly it's quite subjective!

Remember - the goal is that the test names are informative so that when they fail there is some indication of what the test pertains to. A useful exercise to evaluate this is to run pytest with the verbose option, e.g. pytest -v networkx/algorithms/tests/test_lowest_common_ancestors.py

networkx/algorithms/tests/test_lowest_common_ancestors.py Outdated Show resolved Hide resolved
@tindi-plus
Copy link
Contributor Author

Thank you @rossbar for the suggestions. Working on it right away.

@tindi-plus
Copy link
Contributor Author

Hello @rossbar, I think I need help with suitable names on lines 157 and 275. Thank you.

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Generally I think the renaming here is good, thanks @tindi-plus .

One final piece of the cleanup would be to remove the docstrings which are redundant. Again, this is another subjective thing so there is no right answer, but many of the test descriptions in the docstrings are redundant now that the test names are more accurate.

@tindi-plus
Copy link
Contributor Author

Hello @rossbar, suggestions implemented. Redundant docstrings removed.
Thank you for reviewing.

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Thanks @tindi-plus I took the liberty of pushing up just a few final suggestions, but this LGTM!

@tindi-plus
Copy link
Contributor Author

Thank you @rossbar for the entire engagement.

Copy link
Member

@MridulS MridulS left a comment

Choose a reason for hiding this comment

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

Thanks @tindi-plus !

@MridulS MridulS merged commit 3724ba4 into networkx:main Oct 31, 2022
@jarrodmillman jarrodmillman added this to the networkx-2.8.8 milestone Oct 31, 2022
jarrodmillman pushed a commit that referenced this pull request Nov 1, 2022
* Renamed test functions in test_lowest_common_ancestors

* Updated test method names.

* Removed redundant docstrings

* Minor touchups.

Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
MridulS pushed a commit to MridulS/networkx that referenced this pull request Feb 4, 2023
* Renamed test functions in test_lowest_common_ancestors

* Updated test method names.

* Removed redundant docstrings

* Minor touchups.

Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
cvanelteren pushed a commit to cvanelteren/networkx that referenced this pull request Apr 22, 2024
* Renamed test functions in test_lowest_common_ancestors

* Updated test method names.

* Removed redundant docstrings

* Minor touchups.

Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants