code: def test_with_statement_same_attribute(self):
      with patch(
          "%s.something" % __name__, sentinel.Patched
      ) as mock_something:
          self.assertEqual(something, mock_something, "unpatched")
  
          with patch("%s.something" % __name__) as mock_again:
              self.assertEqual(something, mock_again, "unpatched")
  
          self.assertEqual(
              something, mock_something, "restored with wrong instance"
          )
  
      self.assertEqual(something, sentinel.Something, "not restored")
  
imports: import unittest
  from warnings import catch_warnings
  from test.test_unittest.testmock.support import is_instance
  from unittest.mock import MagicMock, Mock, patch, sentinel, mock_open, call
label_desc: Use image node_id 9 for calling the WithTest obj's underlying member method code with example usage: obj.test_with_statement_same_attribute() without return types