Ticket #14290: 14290.patch

File 14290.patch, 1.1 KB (added by roed, 9 years ago)
  • sage/doctest/control.py

    # HG changeset patch
    # User David Roe <roed.math@gmail.com>
    # Date 1363506849 21600
    # Node ID 95b31a44402f4afc05e9653dc38c0692da739c07
    # Parent  3c2703dcc290b4ce96d18590b7598090772f86b4
    Fix interaction between Ipython coloring the output and running doctests from the command line.
    
    diff --git a/sage/doctest/control.py b/sage/doctest/control.py
    a b  
    840840    if options is None:
    841841        options = DocTestDefaults()
    842842    DC = DocTestController(options, F)
     843
     844    # Determine whether we're in doctest mode
    843845    import sage.plot.plot
    844846    save_dtmode = sage.plot.plot.DOCTEST_MODE
     847
     848    # We need the following if we're not in DOCTEST_MODE
     849    # Tell IPython to avoid colors: it screws up the output checking.
     850    if not save_dtmode:
     851        IP = get_ipython()
     852        old_color = IP.colors
     853        IP.run_line_magic('colors','NoColor')
     854
    845855    try:
    846856        DC.run()
    847857    finally:
    848858        sage.plot.plot.DOCTEST_MODE = save_dtmode
     859        if not save_dtmode:
     860            IP.run_line_magic('colors',old_color)