



'''simple docstring'''





import unittest

from transformers.testing_utils import CaptureStdout
from transformers.tools.python_interpreter import evaluate




def lowerCAmelCase						(__A):



     """simple docstring"""



     return x + 2






class __A    (						unittest.TestCase		):



 '''simple docstring'''







 def       a__						(self )					->  Dict:


      """simple docstring"""



      _a											=						'''x = 3'''
      _a											=						{}
      _a											=						evaluate(A				,     {}				,     state=A )
      assert result == 3
      self.assertDictEqual(A				,     {'''x''': 3} )

      _a											=						'''x = y'''
      _a											=						{'''y''': 5}
      _a											=						evaluate(A				,     {}				,     state=A )
      # evaluate returns the value of the last assignment.
      assert result == 5
      self.assertDictEqual(A				,     {'''x''': 5, '''y''': 5} )



 def       a__						(self )					->  Optional[int]:


      """simple docstring"""



      _a											=						'''y = add_two(x)'''
      _a											=						{'''x''': 3}
      _a											=						evaluate(A				,     {'''add_two''': add_two}				,     state=A )
      assert result == 5
      self.assertDictEqual(A				,     {'''x''': 3, '''y''': 5} )

      # Won't work without the tool
      with CaptureStdout() as out:
           _a											=						evaluate(A				,     {}				,     state=A )
      assert result is None
      assert "tried to execute add_two" in out.out



 def       a__						(self )					->  Optional[int]:


      """simple docstring"""



      _a											=						'''x = 3'''
      _a											=						{}
      _a											=						evaluate(A				,     {}				,     state=A )
      assert result == 3
      self.assertDictEqual(A				,     {'''x''': 3} )



 def       a__						(self )					->  Union[str, Any]:


      """simple docstring"""



      _a											=						'''test_dict = {\'x\': x, \'y\': add_two(x)}'''
      _a											=						{'''x''': 3}
      _a											=						evaluate(A				,     {'''add_two''': add_two}				,     state=A )
      self.assertDictEqual(A				,     {'''x''': 3, '''y''': 5} )
      self.assertDictEqual(A				,     {'''x''': 3, '''test_dict''': {'''x''': 3, '''y''': 5}} )



 def       a__						(self )					->  Union[str, Any]:


      """simple docstring"""



      _a											=						'''x = 3\ny = 5'''
      _a											=						{}
      _a											=						evaluate(A				,     {}				,     state=A )
      # evaluate returns the value of the last assignment.
      assert result == 5
      self.assertDictEqual(A				,     {'''x''': 3, '''y''': 5} )



 def       a__						(self )					->  List[str]:


      """simple docstring"""



      _a											=						'''text = f\'This is x: {x}.\''''
      _a											=						{'''x''': 3}
      _a											=						evaluate(A				,     {}				,     state=A )
      # evaluate returns the value of the last assignment.
      assert result == "This is x: 3."
      self.assertDictEqual(A				,     {'''x''': 3, '''text''': '''This is x: 3.'''} )



 def       a__						(self )					->  List[Any]:


      """simple docstring"""



      _a											=						'''if x <= 3:\n    y = 2\nelse:\n    y = 5'''
      _a											=						{'''x''': 3}
      _a											=						evaluate(A				,     {}				,     state=A )
      # evaluate returns the value of the last assignment.
      assert result == 2
      self.assertDictEqual(A				,     {'''x''': 3, '''y''': 2} )

      _a											=						{'''x''': 8}
      _a											=						evaluate(A				,     {}				,     state=A )
      # evaluate returns the value of the last assignment.
      assert result == 5
      self.assertDictEqual(A				,     {'''x''': 8, '''y''': 5} )



 def       a__						(self )					->  int:


      """simple docstring"""



      _a											=						'''test_list = [x, add_two(x)]'''
      _a											=						{'''x''': 3}
      _a											=						evaluate(A				,     {'''add_two''': add_two}				,     state=A )
      self.assertListEqual(A				,     [3, 5] )
      self.assertDictEqual(A				,     {'''x''': 3, '''test_list''': [3, 5]} )



 def       a__						(self )					->  List[str]:


      """simple docstring"""



      _a											=						'''y = x'''
      _a											=						{'''x''': 3}
      _a											=						evaluate(A				,     {}				,     state=A )
      assert result == 3
      self.assertDictEqual(A				,     {'''x''': 3, '''y''': 3} )



 def       a__						(self )					->  Optional[Any]:


      """simple docstring"""



      _a											=						'''test_list = [x, add_two(x)]\ntest_list[1]'''
      _a											=						{'''x''': 3}
      _a											=						evaluate(A				,     {'''add_two''': add_two}				,     state=A )
      assert result == 5
      self.assertDictEqual(A				,     {'''x''': 3, '''test_list''': [3, 5]} )

      _a											=						'''test_dict = {\'x\': x, \'y\': add_two(x)}\ntest_dict[\'y\']'''
      _a											=						{'''x''': 3}
      _a											=						evaluate(A				,     {'''add_two''': add_two}				,     state=A )
      assert result == 5
      self.assertDictEqual(A				,     {'''x''': 3, '''test_dict''': {'''x''': 3, '''y''': 5}} )



 def       a__						(self )					->  Optional[Any]:


      """simple docstring"""



      _a											=						'''x = 0\nfor i in range(3):\n    x = i'''
      _a											=						{}
      _a											=						evaluate(A				,     {'''range''': range}				,     state=A )
      assert result == 2
      self.assertDictEqual(A				,     {'''x''': 2, '''i''': 2} )








'''simple docstring'''





# This is the module that test_patching.py uses to test patch_submodule()

import os  # noqa: this is just for tests
import os as renamed_os  # noqa: this is just for tests
from os import path  # noqa: this is just for tests
from os import path as renamed_path  # noqa: this is just for tests
from os.path import join  # noqa: this is just for tests
from os.path import join as renamed_join  # noqa: this is just for tests


lowercase_	 =						open  # noqa: we just need to have a builtin inside this module to test it properly



