Ticket #10589: trac_10589doctests_for_fixdoctestsam.patch
File trac_10589doctests_for_fixdoctestsam.patch, 4.6 KB (added by , 7 years ago) 


doc/en/reference/cmd/options.rst
# HG changeset patch # User Andrew Mathas <andrew dot mathas at sydney dot edu dot au> # Date 1367454916 36000 # Node ID f59816192f6345d93f51a8888b0dd5434301e774 # Parent 5ca0aff69ed40d5bace1e1a6378719cba372b35f Doctests and manual updates for the fixdoctests script diff git a/doc/en/reference/cmd/options.rst b/doc/en/reference/cmd/options.rst
a b for Sage: 169 169  ``long``  include lines with the phrase 'long time' 170 170  ``verbose``  print debugging output during the test 171 171  ``optional``  also test all examples labeled ``# optional`` 172  ``onlyoptional[=tags]``  If no ``tags`` are specified, only172  ``onlyoptional[=tags]``  if no ``tags`` are specified, only 173 173 run blocks of tests containing a line labeled ``# optional``. If 174 174 a comma separated list of tags is specified, only run blocks containing 175 175 a line labeled ``# optional tag`` for any of the tags given and in these blocks only … … for Sage: 187 187  ``btp <N> [...]``  build and test in parallel, options like 188 188 ``tp`` above 189 189  ``btnew [...]``  build and test modified files, options like ``tnew`` 190  ``fixdoctests file.py``  create ``file.py.out`` that would 191 pass the doctests and output a patch 190  ``fixdoctests file.py [output_file] [long]``  writes a new 191 version of ``file.py`` to ``output_file`` (default: ``file.py.out``) 192 that will pass the doctests. With the optional ``long`` argument 193 the long time tests are also checked. A patch for the new file is 194 printed to stdout. 192 195  ``startuptime [module]``  display how long each component of Sage takes 193 196 to start up. Optionally specify a module (e.g., "sage.rings.qqbar") to get 194 197 more details about that particular module. 
sage/tests/cmdline.py
diff git a/sage/tests/cmdline.py b/sage/tests/cmdline.py
a b test.spyx 16 16 cython 17 17 ecl 18 18 experimental 19 fixdoctests 19 20 gap 20 21 gdb 21 22 gp … … def test_executable(args, input="", time 400 401 ... 401 402 RuntimeError: refusing to run doctests... 402 403 404 Now run a test for the fixdoctests script and, in particular, check that the 405 issues raised in :trac:`10589` are fixed. We have to go to slightly silly 406 lengths to doctest the output.:: 407 408 sage: test='r\"\"\"Add a doctest for the fixdoctest command line option and, in particular, check that\n:trac:`10589` is fixed.\n\nEXAMPLES::\n\n sage: 1+1 # incorrect output\n 3\n sage: m=matrix(ZZ,3) # output when none is expected\n [0 0 0]\n [0 0 0]\n [1 0 0]\n sage: (2/3)*m # no output when it is expected\n sage: mu=PartitionTuple([[4,4],[3,3,2,1],[1,1]]) # output when none is expected\n [4, 4, 3, 3, 2, 1, 1]\n sage: mu.pp() # uneven indentation\n ****\n ****\n sage: PartitionTuples.global_options(convention="French")\n sage: mu.pp() # fix doctest with uneven indentation\n sage: PartitionTuples.global_options.reset()\n\"\"\"\n' 409 sage: test_file = os.path.join(tmp_dir(), 'test_file.py') 410 sage: F = open(test_file, 'w') 411 sage: F.write(test) 412 sage: F.close() 413 sage: (out, err, ret) = test_executable(["sage", "fixdoctests", test_file]) 414 sage: print err 415 <BLANKLINE> 416 sage: output=out.replace('sage:', 'SAGE:') # so we don't doctest the output 417 sage: print output[output.find(' SAGE: 1+1'):output.find('reset()')+7] 418 SAGE: 1+1 # incorrect output 419  3 420 + 2 421 SAGE: m=matrix(ZZ,3) # output when none is expected 422 + SAGE: (2/3)*m # no output when it is expected 423 [0 0 0] 424 [0 0 0] 425  [1 0 0] 426  SAGE: (2/3)*m # no output when it is expected 427 + [0 0 0] 428 SAGE: mu=PartitionTuple([[4,4],[3,3,2,1],[1,1]]) # output when none is expected 429  [4, 4, 3, 3, 2, 1, 1] 430 SAGE: mu.pp() # uneven indentation 431  **** 432  **** 433 + **** *** * 434 + **** *** * 435 + ** 436 + * 437 SAGE: PartitionTuples.global_options(convention="French") 438 SAGE: mu.pp() # fix doctest with uneven indentation 439 + * 440 + ** 441 + **** *** * 442 + **** *** * 443 SAGE: PartitionTuples.global_options.reset() 444 403 445 Test external programs being called by Sage:: 404 446 405 447 sage: (out, err, ret) = test_executable(["sage", "sh"], "echo Hello World\nexit 42\n")