code: def test_ipythonprinting():
      # Initialize and setup IPython session
      app = init_ipython_session()
      app.run_cell("ip = get_ipython()")
      app.run_cell("inst = ip.instance()")
      app.run_cell("format = inst.display_formatter.format")
      app.run_cell("from sympy import Symbol")
  
      # Printing without printing extension
      app.run_cell("a = format(Symbol('pi'))")
      app.run_cell("a2 = format(Symbol('pi')**2)")
      # Deal with API change starting at IPython 1.0
      if int(ipython.__version__.split(".")[0]) < 1:
          assert app.user_ns["a"]["text/plain"] == "pi"
          assert app.user_ns["a2"]["text/plain"] == "pi**2"
      else:
          assert app.user_ns["a"][0]["text/plain"] == "pi"
          assert app.user_ns["a2"][0]["text/plain"] == "pi**2"
  
      # Load printing extension
      app.run_cell("from sympy import init_printing")
      app.run_cell("init_printing()")
      # Printing with printing extension
      app.run_cell("a = format(Symbol('pi'))")
      app.run_cell("a2 = format(Symbol('pi')**2)")
      # Deal with API change starting at IPython 1.0
      if int(ipython.__version__.split(".")[0]) < 1:
          assert app.user_ns["a"]["text/plain"] in (
              "\N{GREEK SMALL LETTER PI}",
              "pi",
          )
          assert app.user_ns["a2"]["text/plain"] in (
              " 2\n\N{GREEK SMALL LETTER PI} ",
              "  2\npi ",
          )
      else:
          assert app.user_ns["a"][0]["text/plain"] in (
              "\N{GREEK SMALL LETTER PI}",
              "pi",
          )
          assert app.user_ns["a2"][0]["text/plain"] in (
              " 2\n\N{GREEK SMALL LETTER PI} ",
              "  2\npi ",
          )
  
file_path: sympy/sympy/interactive/tests/test_ipython.py
imports: from sympy.interactive.session import init_ipython_session, enable_automatic_symbols, enable_automatic_int_sympification
  from sympy.core import Symbol, Rational, Integer
  from sympy.external import import_module
  from sympy.testing.pytest import raises
label_desc: Use image node_id 3 for calling a global function with example usage: test_ipythonprinting() without return types