Summary:
The current error message is a bit noisy. Let's just get to the point about the
filename and line number that is interesting without tracebacks. This only
affects functions using the `autofix.eq` API, other kinds of exceptions will
have tracebacks as usual.
Before, run-tests.py (19 lines):
--- test-empty-t.py.out
+++ test-empty-t.py.err
@@ -0,0 +1,14 @@
+Traceback (most recent call last):
+ File "hg/tests/test-empty-t.py", line 71, in <module>
+ """
+ File "hg/tests/testutil/dott/shobj.py", line 89, in __eq__
+ autofix.eq(out, rhs, nested=1, eqfunc=eqglob)
+ File "hg/tests/testutil/autofix.py", line 93, in eq
+ raise AssertionError("actual != expected\n%s" % diff)
+AssertionError: actual != expected
+--- expected
++++ actual
+@@ -1 +1 @@
+-someheads
++allheads
+
ERROR: test-empty-t.py output changed
Before, run directly via python (13 lines):
Traceback (most recent call last):
File "test-empty-t.py", line 71, in <module>
"""
File "hg/tests/testutil/dott/shobj.py", line 89, in __eq__
autofix.eq(out, rhs, nested=1, eqfunc=eqglob)
File "hg/tests/testutil/autofix.py", line 93, in eq
raise AssertionError("actual != expected\n%s" % diff)
AssertionError: actual != expected
--- expected
+++ actual
@@ -1 +1 @@
-someheads
+allheads
After, run-tests.py (8 lines):
--- test-empty-t.py:71 (expected)
+++ test-empty-t.py:71 (actual)
@@ -1 +1 @@
-someheads
+allheads
ERROR: test-empty-t.py output changed
After, run directly (5 lines):
% python test-empty-t.py
--- test-empty-t.py:71 (expected)
+++ test-empty-t.py:71 (actual)
@@ -1 +1 @@
-someheads
+allheads
Reviewed By: xavierd
Differential Revision: D17277286
fbshipit-source-id: a48d4d1e817f67e221a901977e0c0f8bdc1a62ab
Summary:
Comparing to `.t` tests, `dott` Python tests cannot autofix commands without
outputs. This diff makes it able to do so. It's less strict than the AST
parsing (for example, it does not handle `#` comments precisely). But
practically it might be good enough. We can update it to use real AST parsing
if it becomes an issue.
This should make `dott` Python tests easier to use.
Reviewed By: xavierd
Differential Revision: D17277285
fbshipit-source-id: 11ef6ec4327a6547d49b544c63bc000a3c351947
Summary:
The `_repr` implementation can generate docstrings with trailing spaces if
`indent` is > 0.
Fix it by special handling the blank line case.
Reviewed By: xavierd
Differential Revision: D16452935
fbshipit-source-id: 99704ba3fb30b93aa35ba4fb16c1d853c58c6635
Summary:
To make the code look better, indentation gets added to heredoc content.
Remove them. This replaces `inspect.cleandoc`. The difference is
`inspect.cleandoc` special handles the first line, which is undesirable.
Reviewed By: xavierd
Differential Revision: D16344716
fbshipit-source-id: c69c20607ddc5292bc6bcdd840587258276016ed
Summary: The "eq" API is similar to `assert_eq!` in Rust, with the autofix ability.
Reviewed By: xavierd
Differential Revision: D16168821
fbshipit-source-id: bf7dcfd24c42dee30c54aeeaa71eccab78a8f0f6