Skip to content

Commit

Permalink
Add very verbose option (#22)
Browse files Browse the repository at this point in the history
Pytest has an option for higher verbosity, which will display the full diff for objects that fail equality assertion (-vv). In my work, I've found the flag to be indispensable for TDD. This PR adds the -vv flag as an option in the magit popup menu.

Co-authored-by: Ryan Pilgrim <ryan.pilgrim@infiniaml.com>
  • Loading branch information
r-zip and Ryan Pilgrim authored Jul 30, 2020
1 parent dd05959 commit 6d8538a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion python-pytest.el
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ When non-nil only ‘test_foo()’ will match, and nothing else."
(defvar-local python-pytest--current-command nil
"Current command; used in python-pytest-mode buffers.")

(defvar-local python-pytest--verbosity-level 0
"Verbosity level.")

(fmakunbound 'python-pytest-popup)
(makunbound 'python-pytest-popup)

Expand All @@ -132,7 +135,7 @@ When non-nil only ‘test_foo()’ will match, and nothing else."
(?q "quiet" "--quiet")
(?s "do not capture output" "--capture=no")
(?t "do not cut tracebacks" "--full-trace")
(?v "verbose" "--verbose")
(?v "verbose" python-pytest--cycle-verbosity)
(?x "exit after first failure" "--exitfirst"))
:options
'((?k "only names matching expression" "-k")
Expand Down Expand Up @@ -561,6 +564,18 @@ Example: ‘MyABCThingy.__repr__’ becomes ‘test_my_abc_thingy_repr’."
(t nil)))


(defun python-pytest--cycle-verbosity ()
"Cycle the verbosity level from 0 (no -v flag) to 2 (-vv flag)."
(cond
((memq python-pytest--verbosity '(0 1))
(setq python-pytest--verbosity (+ 1 python-pytest--verbosity)))
(t (setq python-pytest--verbosity 0)))
(cond
((= python-pytest--verbosity 0) "")
((= python-pytest--verbosity 1) "-v")
((= python-pytest--verbosity 2) "-vv")))


;; third party integration

(with-eval-after-load 'direnv
Expand Down

0 comments on commit 6d8538a

Please sign in to comment.