Opened 11 months ago

Closed 9 months ago

Last modified 9 months ago

#26881 closed enhancement (fixed)

py3: make doctest pass in repl module

Reported by: vklein Owned by:
Priority: major Milestone: sage-8.7
Component: python3 Keywords:
Cc: Merged in:
Authors: Vincent Klein Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 13b9f22 (Commits) Commit:
Dependencies: Stopgaps:

Description (last modified by vklein)

Fix the failling doctests in the sage.repl module :

sage -t --long src/sage/repl/configuration.py  # 2 doctests failed
sage -t --long src/sage/repl/ipython_tests.py  # 5 doctests failed
sage -t --long src/sage/repl/interpreter.py  # 1 doctest failed
sage -t --long src/sage/repl/ipython_kernel/widgets_sagenb.py  # 2 doctests failed
sage -t --long src/sage/repl/ipython_kernel/interact.py  # 1 doctest failed

Change History (10)

comment:1 Changed 11 months ago by chapoton

  • Milestone changed from sage-8.5 to sage-8.7

comment:2 Changed 9 months ago by vklein

  • Branch set to u/vklein/26881

comment:3 Changed 9 months ago by vklein

  • Commit set to 13b9f224e8b2860a7e15289331e010f06f4387cf
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

13b9f22Trac #26881: py3 Fix repl module for python3

comment:4 Changed 9 months ago by vklein

  • Description modified (diff)

comment:5 Changed 9 months ago by vklein

  • Description modified (diff)

comment:6 Changed 9 months ago by chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

Well, I find it suspect that OrderedDict? does not display in the given order in py2..

But let us keep that for another ticket..

comment:7 Changed 9 months ago by vbraun

  • Branch changed from u/vklein/26881 to 13b9f224e8b2860a7e15289331e010f06f4387cf
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:8 Changed 9 months ago by chapoton

  • Commit 13b9f224e8b2860a7e15289331e010f06f4387cf deleted

I still get

sage -t --long src/sage/repl/attach.py  # 4 doctests failed

namely

sage -t --long src/sage/repl/attach.py
**********************************************************************
File "src/sage/repl/attach.py", line 36, in sage.repl.attach
Failed example:
    try:
        attach(src)
    except Exception:
        traceback.print_exc()
Expected:
    Traceback (most recent call last):
    ...
        exec(preparse_file(f.read()) + "\n", globals)
      File "<string>", line 3, in <module>
    ValueError: third
Got:
    <BLANKLINE>
**********************************************************************
File "src/sage/repl/attach.py", line 45, in sage.repl.attach
Failed example:
    detach(src)
Expected nothing
Got:
    Traceback (most recent call last):
      File "<doctest sage.repl.attach[10]>", line 2, in <module>
        attach(src)
      File "sage/misc/lazy_import.pyx", line 354, in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:3683)
        return self.get_object()(*args, **kwds)
      File "/home/u1/chapoton/sage3/local/lib/python3.6/site-packages/sage/repl/attach.py", line 356, in attach
        load(filename, globals(), attach=True)
      File "/home/u1/chapoton/sage3/local/lib/python3.6/site-packages/sage/repl/load.py", line 272, in load
        exec(preparse_file(f.read()) + "\n", globals)
      File "<string>", line 3, in <module>
    ValueError: third
**********************************************************************
File "src/sage/repl/attach.py", line 48, in sage.repl.attach
Failed example:
    try:
        attach(src)
    except Exception:
        traceback.print_exc()
Expected:
    Traceback (most recent call last):
    ...
        exec(code, globals)
      File ".../foobar.sage....py", line ..., in <module>
        raise ValueError("third")   # this should appear in the source snippet
    ValueError: third
Got:
    <BLANKLINE>
**********************************************************************
File "src/sage/repl/attach.py", line 58, in sage.repl.attach
Failed example:
    detach(src)
Expected nothing
Got:
    Traceback (most recent call last):
      File "<doctest sage.repl.attach[13]>", line 2, in <module>
        attach(src)
      File "sage/misc/lazy_import.pyx", line 354, in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:3683)
        return self.get_object()(*args, **kwds)
      File "/home/u1/chapoton/sage3/local/lib/python3.6/site-packages/sage/repl/attach.py", line 356, in attach
        load(filename, globals(), attach=True)
      File "/home/u1/chapoton/sage3/local/lib/python3.6/site-packages/sage/repl/load.py", line 266, in load
        exec(code, globals)
      File "/home/u1/chapoton/.sage/temp/atlas/6848/foobar.sage8jw3wb2i.py", line 7, in <module>
        raise ValueError("third")   # this should appear in the source snippet
    ValueError: third

comment:9 Changed 9 months ago by vklein

I don't get that attach.py tests pass (as the whole module) in py2 and py3 on my computers. Do you use optional modules ?

comment:10 Changed 9 months ago by chapoton

indeed, the tests pass when run alone on the patchbot machine and another machine. So they only fail in the patchbot run.

Note that the failures seems to be a shift in the answers: each doctests receives the output of the previous doctest..

Note: See TracTickets for help on using tickets.