Commit Graph

8 Commits

Author SHA1 Message Date
Gregory Szorc
8cca557cf0 tests: use absolute_import for heredoctest.py 2015-12-06 22:26:12 -08:00
Augie Fackler
0633899f59 heredoctest: 2to3 -w -f numliterals -f except -f print tests/heredoctest.py 2015-04-12 15:34:17 -04:00
Yuya Nishihara
7c09e032d1 heredoctest: do not append extra newline character to continuation line
Trailing newline characters are kept in lines.
2014-09-28 15:13:35 +09:00
Yuya Nishihara
c82190e72c heredoctest: use the same dict for local/global contexts as in doctest
In order to mimic module-level evaluation, globals and locals should be the
same object, so doctest does not pass separate locals dict.

https://docs.python.org/2.7/reference/simple_stmts.html#exec

This fixes NameError in the following example:

    >>> import foo
    >>> def bar():
    ...     foo  # must exist in globalvars
2014-09-28 14:15:43 +09:00
Matt Mackall
17d82e7fd5 run-tests: replace inline python handling with more native scheme
Normally changes in tests are reported like this in diffs:

   $ cat foo
-  a
+  b

Using -i mode lets us update tests when the new results are correct
and/or populate tests with their output.

But with the standard doctest framework, inline Python sections in
tests changes instead result in a big failure report that's unhelpful.
So here, we replace the doctest calls with a simple compile/eval loop.
2011-11-07 13:46:41 -06:00
Brodie Rao
114ca03d36 tests: fix readline escape characters in heredoctest.py/test-url.py
This fix mirrors the changes made to test-doctest.py in 04cfbbc5ae97
and 39599b7929c4.

Without this change, tests running heredoctest.py can fail on certain
versions of OS X when TERM is set to xterm-256color:

   $ /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -m heredoctest <<EOF
   > >>> open('b', 'w').write('this' * 1000)
   > EOF
+  \x1b[?1034h (no-eol) (esc)

A similar problem occurs with test-url.py:

  $ ./run-tests.py test-url.py

  --- .../tests/test-url.py.out
  +++ .../tests/test-url.py.err
  @@ -0,0 +1 @@
  +
  ERROR: .../test-url.py output changed
  !
  Failed test-url.py: output changed
  # Ran 1 tests, 0 skipped, 1 failed.
2011-11-01 12:25:54 -07:00
Idan Kamara
03e76d64ac tests: remove temp doctest file when finished running it 2011-10-13 17:54:35 +02:00
Idan Kamara
36075d5498 tests: add helper script for processing doctests read from stdin
Writes stdin to a temp file and doctests it.

In the future we might want to spare the temp file and directly call into
doctest.

Also, with some tweaking it seems possible to adjust the line numbers reported
in an error report so they match the ones in the original file.
2011-10-12 22:01:13 +02:00