Skip to content

Commit 6d8538a

Browse files
r-zipRyan Pilgrim
andauthored
Add very verbose option (#22)
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 <[email protected]>
1 parent dd05959 commit 6d8538a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

python-pytest.el

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ When non-nil only ‘test_foo()’ will match, and nothing else."
116116
(defvar-local python-pytest--current-command nil
117117
"Current command; used in python-pytest-mode buffers.")
118118

119+
(defvar-local python-pytest--verbosity-level 0
120+
"Verbosity level.")
121+
119122
(fmakunbound 'python-pytest-popup)
120123
(makunbound 'python-pytest-popup)
121124

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

563566

567+
(defun python-pytest--cycle-verbosity ()
568+
"Cycle the verbosity level from 0 (no -v flag) to 2 (-vv flag)."
569+
(cond
570+
((memq python-pytest--verbosity '(0 1))
571+
(setq python-pytest--verbosity (+ 1 python-pytest--verbosity)))
572+
(t (setq python-pytest--verbosity 0)))
573+
(cond
574+
((= python-pytest--verbosity 0) "")
575+
((= python-pytest--verbosity 1) "-v")
576+
((= python-pytest--verbosity 2) "-vv")))
577+
578+
564579
;; third party integration
565580

566581
(with-eval-after-load 'direnv

0 commit comments

Comments
 (0)