Skip to content

Conversation

@leonqadirie
Copy link

While returning a copy (not altering the original) makes more sense in the provided setting, this is:

  • not tested.
  • encourages just using the sorted() function instead of the copy() and sort() methods I suspect we want to see in this exercise - as it introduces the list method concept..

If we want to test for the returned value being a copy, keeping the original intact, this might be the corrected test:

@pytest.mark.task(taskno=7)
    def test_sorted_names(self):
        test_data = ["Steve", "Ultron", "Natasha", "Rocket"]
        test_data_copy = test_data.copy()
        expected = ["Natasha", "Rocket", "Steve", "Ultron"]
        actual_result = sorted_names(test_data)

        error_message = (
            f"Called sorted_names({test_data})."
            f"The function returned {actual_result}, but the tests "
            f"expected {expected}."
        )

        self.assertListEqual(actual_result, expected, msg=error_message)
        self.assertListEqual(
            test_data,
            test_data_copy,
            msg="Function should not modify the original list",
        )

While returning a copy makes more sense semantically, this is:
* not tested
* encourages just using the `sorted()` function instead of the `copy().sort()` method I suspect we want to see in this exercise.
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

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.

1 participant