Skip to content

Revise test_assignment.py so that assert failure message are distinct. #1941

Description

@rocky

Test assert failures should have distinct failure messages.

Consider:

        (
            "A=1; B=2; Clear[A, $Context, B];{A,$Context,B}",
            "{A, Global`, B}",
            "This clears A and B, but not $Context",
            ("Special symbol $Context cannot be cleared.",),
        ),
        (
            "A=1; B=2; ClearAll[A, $Context, B];{A,$Context,B}",
            "{A, Global`, B}",
            "This clears A and B, but not $Context",
            ("Special symbol $Context cannot be cleared.",),
        ),

When we run the test and if it fails, it is not immediately clear which of the two similar tests is failing from the failure message.

Better:

```python
        (
            "A=1; B=2; Clear[A, $Context, B];{A,$Context,B}",
            "{A, Global`, B}",
            "This clears A and B via Clear, but not $Context",
            ("Special symbol $Context cannot be cleared.",),
        ),
        (
            "A=1; B=2; ClearAll[A, $Context, B];{A,$Context,B}",
            "{A, Global`, B}",
            "This clears A and B via ClearAll, but not $Context",
            ("Special symbol $Context cannot be cleared.",),
        ),

The failure message also makes it easier to tell what is different between the two similar tests.

There are numerous other examples in test_assignment and possibly elsewhere.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ChoreNot a bug per se, but something that should be done to improve the code or its clarity.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions