class_docstr: Test for Magic
  The test counts the number of substitutions that magic.add_code do for
  a few code snippets. The test passes if the expected number of
  substitutions have been made.
class_docstr_tok: ["Test","for","Magic","The","test","counts","the","number","of","substitutions","that","magic.add_code","do","for","a","few","code","snippets",".","The","test","passes","if","the","expected","number","of","substitutions","have","been","made","."]
docstr: Test that magic.displayLastExprIfNoSemicolon causes the last function ast.Expr
  node in a file to be wrapped in st.write().
docstr_tok: ["Test","that","magic.displayLastExprIfNoSemicolon","causes","the","last","function","ast.Expr","node","in","a","file","to","be","wrapped","in","st.write","(",")","."]
code: def test_display_last_expr_config_option(self):
      """Test that magic.displayLastExprIfNoSemicolon causes the last function ast.Expr
      node in a file to be wrapped in st.write()."""
  
      CODE_WITHOUT_SEMICOLON = """
  this_should_not_be_magicked()
  
  def my_func():
      this_should_not_be_magicked()
  
  class MyClass:
      this_should_not_be_magicked()
  
      def __init__(self):
          this_should_not_be_magicked()
  
  this_is_the_last_expr()
  
  # Some newlines for good measure
  
  
  """
  
      self._testCode(CODE_WITHOUT_SEMICOLON, 0)
  
      with patch_config_options(
          {"magic.displayLastExprIfNoSemicolon": True}
      ):
          self._testCode(CODE_WITHOUT_SEMICOLON, 1)
  
      with patch_config_options(
          {"magic.displayLastExprIfNoSemicolon": False}
      ):
          self._testCode(CODE_WITHOUT_SEMICOLON, 0)
  
      CODE_WITH_SEMICOLON = """
  this_should_not_be_magicked()
  
  def my_func():
      this_should_not_be_magicked()
  
  class MyClass:
      this_should_not_be_magicked()
  
      def __init__(self):
          this_should_not_be_magicked()
  
  this_is_the_last_expr();
  
  # Some newlines for good measure
  
  
  """
  
      self._testCode(CODE_WITH_SEMICOLON, 0)
  
      with patch_config_options(
          {"magic.displayLastExprIfNoSemicolon": True}
      ):
          self._testCode(CODE_WITH_SEMICOLON, 0)
  
      with patch_config_options(
          {"magic.displayLastExprIfNoSemicolon": False}
      ):
          self._testCode(CODE_WITH_SEMICOLON, 0)
  
imports: import ast
  import unittest
  import streamlit.runtime.scriptrunner.magic
  from tests.testutil import patch_config_options
label_desc: Use image node_id 18 for calling the MagicTest obj's underlying member method code with example usage: obj.test_display_last_expr_config_option() without return types