from __future__ import print_function, division, absolute_import

import subprocess
import sys
import os

def test_IPython():
    ipython = os.path.join(sys.prefix, 'bin', 'ipython')
    if not os.path.exists(ipython):
        raise Exception("IPython must be installed in %s to run the IPython tests" % os.path.join(sys.prefix, 'bin'))


    commands = b"""\
1

raise Exception
undefined
def f():
    pass

f()

"""
    p = subprocess.Popen([ipython, '--quick', '--colors=LightBG', '--no-banner'],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    stdout, stderr = p.communicate(input=commands)
    assert (stdout, stderr) == (b'', b'')

from __future__ import print_function, division, absolute_import

import subprocess
import sys
import os

from IPython.testing.tools import get_ipython_cmd

def test_IPython():
    ipython = get_ipython_cmd()

    commands = b"""\
1

raise Exception
undefined
def f():
    pass

f()

"""
    p = subprocess.Popen([ipython, '--quick', '--colors=LightBG', '--no-banner'],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    stdout, stderr = p.communicate(input=commands)
    assert (stdout, stderr) == (b'', b'')

Use get_ipython_cmd in IPython test
Use get_ipython_cmd in IPython test

  from __future__ import print_function, division, absolute_import
  
  import subprocess
  import sys
  import os
  
+ from IPython.testing.tools import get_ipython_cmd
+ 
  def test_IPython():
+     ipython = get_ipython_cmd()
-     ipython = os.path.join(sys.prefix, 'bin', 'ipython')
-     if not os.path.exists(ipython):
-         raise Exception("IPython must be installed in %s to run the IPython tests" % os.path.join(sys.prefix, 'bin'))
- 
  
      commands = b"""\
  1
  
  raise Exception
  undefined
  def f():
      pass
  
  f()
  
  """
      p = subprocess.Popen([ipython, '--quick', '--colors=LightBG', '--no-banner'],
          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  
      stdout, stderr = p.communicate(input=commands)
      assert (stdout, stderr) == (b'', b'')
  
Use get_ipython_cmd in IPython test
## Code Before:
from __future__ import print_function, division, absolute_import

import subprocess
import sys
import os

def test_IPython():
    ipython = os.path.join(sys.prefix, 'bin', 'ipython')
    if not os.path.exists(ipython):
        raise Exception("IPython must be installed in %s to run the IPython tests" % os.path.join(sys.prefix, 'bin'))


    commands = b"""\
1

raise Exception
undefined
def f():
    pass

f()

"""
    p = subprocess.Popen([ipython, '--quick', '--colors=LightBG', '--no-banner'],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    stdout, stderr = p.communicate(input=commands)
    assert (stdout, stderr) == (b'', b'')

## Instruction:
Use get_ipython_cmd in IPython test
## Code After:
from __future__ import print_function, division, absolute_import

import subprocess
import sys
import os

from IPython.testing.tools import get_ipython_cmd

def test_IPython():
    ipython = get_ipython_cmd()

    commands = b"""\
1

raise Exception
undefined
def f():
    pass

f()

"""
    p = subprocess.Popen([ipython, '--quick', '--colors=LightBG', '--no-banner'],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    stdout, stderr = p.communicate(input=commands)
    assert (stdout, stderr) == (b'', b'')
