def test_assertion_walrus_different_test_cases(self, pytester: Pytester) -> None:
        """Regression for (#11239)

        Walrus operator rewriting would leak to separate test cases if they used the same variables.
        """
        pytester.makepyfile(
            """
            def test_1():
                state = {"x": 2}.get("x")
                assert state is not None

            def test_2():
                db = {"x": 2}
                assert (state := db.get("x")) is not None
        """
        )
        result = pytester.runpytest()
        assert result.ret == 0
Regression for (#11239)

        Walrus operator rewriting would leak to separate test cases if they used the same variables.
        
testing/test_assertrewrite.py