Skip to content

error() is not printing the value of the variable when assert expression only contains that variable #1

@vzakaznikov

Description

@vzakaznikov
with Module("regression"):
    with Scenario("my test"):
        with Check("my check"):
            value = False
            result = snapshot(value,id="my_test",name="my_check")
            assert result, error()

produces the following output where the value of the result is not printed.

Jun 16,2023 8:03:36       ⟥  Check my check
                42ms       ⟥    Exception: Traceback (most recent call last):
                                    File "/home/user/Projects/Altinity/training/davit/using_snapshots/test.py", line 9, in <module>
                                      assert result, error()
                                  AssertionError: Oops! Assertion failed

                                  The following assertion was not satisfied
                                    assert result, error()

                                  Assertion values
                                    assert result, error()
                                    ^ is False

                                  Where
                                    File '/home/user/Projects/Altinity/training/davit/using_snapshots/test.py', line 9 in '<module>'

                                   1|  from testflows.core import *
                                   2|  from testflows.asserts import snapshot, values, error
                                   3|  
                                   4|  with Module("regression"):
                                   5|      with Scenario("my test"):
                                   6|          with Check("my check"):
                                   7|              value = False
                                   8|              result = snapshot(value,id="my_test",name="my_check")
                                   9|>             assert result, error()
                                  10|  
                                  11|

instead we want to see output similar to

                         Assertion values
                           assert result and True, error()
                                  ^ is SnapshotError(
                           filename=/home/user/Projects/Altinity/training/davit/using_snapshots/snapshots/test.py.my_test.snapshot
                           name=my_check
                           snapshot_value="""
                               True""",
                           actual_value="""
                               False""",
                           diff="""
                               --- /home/user/Projects/Altinity/training/davit/using_snapshots/snapshots/test.py.my_test.snapshot
                               +++ 
                               @@ -1 +1 @@
                               -True
                               +False
                           """)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions