|
2 | 2 |
|
3 | 3 | ;; Author: wouter bolsterlee <[email protected]> |
4 | 4 | ;; Version: 1.0.0 |
5 | | -;; Package-Requires: ((emacs "24.4") (dash "2.12.0") (dash-functional "2.12.0") (magit-popup "2.12.0") (projectile "0.14.0") (s "1.12.0")) |
| 5 | +;; Package-Requires: ((emacs "24.4") (dash "2.12.0") (dash-functional "2.12.0") (transient "20200719") (projectile "0.14.0") (s "1.12.0")) |
6 | 6 | ;; Keywords: pytest, test, python, languages, processes, tools |
7 | 7 | ;; URL: https://github.com/wbolster/emacs-python-pytest |
8 | 8 | ;; |
|
25 | 25 |
|
26 | 26 | (require 'dash) |
27 | 27 | (require 'dash-functional) |
28 | | -(require 'magit-popup) |
| 28 | +(require 'transient) |
29 | 29 | (require 'projectile) |
30 | 30 | (require 's) |
31 | 31 |
|
@@ -116,44 +116,42 @@ When non-nil only ‘test_foo()’ will match, and nothing else." |
116 | 116 | (defvar-local python-pytest--current-command nil |
117 | 117 | "Current command; used in python-pytest-mode buffers.") |
118 | 118 |
|
119 | | -(fmakunbound 'python-pytest-popup) |
120 | | -(makunbound 'python-pytest-popup) |
121 | | - |
122 | | -;;;###autoload (autoload 'python-pytest-popup "python-pytest" nil t) |
123 | | -(magit-define-popup python-pytest-popup |
| 119 | +;;;###autoload (autoload 'python-pytest-dispatch "python-pytest" nil t) |
| 120 | +(define-transient-command python-pytest-dispatch () |
124 | 121 | "Show popup for running pytest." |
125 | | - 'python-pytest |
126 | | - :switches |
127 | | - '((?c "color" "--color" t) |
128 | | - (?d "run doctests" "--doctest-modules") |
129 | | - (?f "failed first" "--failed-first") |
130 | | - (?l "show locals" "--showlocals") |
131 | | - (?p "debug on error" "--pdb") |
132 | | - (?q "quiet" "--quiet") |
133 | | - (?s "do not capture output" "--capture=no") |
134 | | - (?t "do not cut tracebacks" "--full-trace") |
135 | | - (?v "verbose" "--verbose") |
136 | | - (?w "very verbose" "-vv") |
137 | | - (?x "exit after first failure" "--exitfirst")) |
138 | | - :options |
139 | | - '((?k "only names matching expression" "-k") |
140 | | - (?m "only marks matching expression" "-m") |
141 | | - (?t "traceback style" "--tb=" python-pytest--choose-traceback-style) |
142 | | - (?x "exit after N failures or errors" "--maxfail=")) |
143 | | - :actions |
144 | | - '("Run tests" |
145 | | - (?t "Test all" python-pytest) |
146 | | - (?r "Repeat last test run" python-pytest-repeat) |
147 | | - (?x "Test last-failed" python-pytest-last-failed) |
148 | | - "Run tests for specific files" |
149 | | - (?f "Test file (dwim)" python-pytest-file-dwim) |
150 | | - (?F "Test this file" python-pytest-file) |
151 | | - (?m "Test multiple files" python-pytest-files) |
152 | | - "Run tests for current function/class" |
153 | | - (?d "Test def/class (dwim)" python-pytest-function-dwim) |
154 | | - (?D "Test this def/class" python-pytest-function)) |
155 | | - :max-action-columns 3 |
156 | | - :default-action 'python-pytest-repeat) |
| 122 | + :man-page "pytest" |
| 123 | + :incompatible '(("--verbose" "--verbose --verbose")) |
| 124 | + :value '("--color") |
| 125 | + ["Switches" |
| 126 | + ("-c" "color" "--color") |
| 127 | + ("-d" "run doctests" "--doctest-modules") |
| 128 | + ("-f" "failed first" "--failed-first") |
| 129 | + ("-l" "show locals" "--showlocals") |
| 130 | + ("-p" "debug on error" "--pdb") |
| 131 | + ("-q" "quiet" "--quiet") |
| 132 | + ("-s" "do not capture output" "--capture=no") |
| 133 | + ("-t" "do not cut tracebacks" "--full-trace") |
| 134 | + ("-v" "verbose" ("-v" "--verbose")) |
| 135 | + ("-w" "very verbose" ("-vv" "--verbose --verbose")) |
| 136 | + ("-x" "exit after first failure" "--exitfirst")] |
| 137 | + ["Options" |
| 138 | + ("=k" "only names matching expression" "-k=") |
| 139 | + ("=m" "only marks matching expression" "-m=") |
| 140 | + (python-pytest-dispatch:--tb) |
| 141 | + ("=x" "exit after N failures or errors" "--maxfail=")] |
| 142 | + [["Run tests" |
| 143 | + ("t" "Test all" python-pytest) |
| 144 | + ("r" "Repeat last test run" python-pytest-repeat) |
| 145 | + ("x" "Test last-failed" python-pytest-last-failed)] |
| 146 | + ["Run tests for specific files" |
| 147 | + ("f" "Test file (dwim)" python-pytest-file-dwim) |
| 148 | + ("F" "Test this file" python-pytest-file) |
| 149 | + ("m" "Test multiple files" python-pytest-files)] |
| 150 | + ["Run tests for current function/class" |
| 151 | + ("d" "Test def/class (dwim)" python-pytest-function-dwim) |
| 152 | + ("D" "Test this def/class" python-pytest-function)]]) |
| 153 | + |
| 154 | +(define-obsolete-function-alias 'python-pytest-popup 'python-pytest-dispatch) |
157 | 155 |
|
158 | 156 | ;;;###autoload |
159 | 157 | (defun python-pytest (&optional args) |
@@ -388,13 +386,12 @@ With a prefix ARG, allow editing." |
388 | 386 |
|
389 | 387 | (defun python-pytest--get-buffer () |
390 | 388 | "Get a create a suitable compilation buffer." |
391 | | - (magit-with-pre-popup-buffer |
392 | | - (if (eq major-mode 'python-pytest-mode) |
393 | | - (current-buffer) ;; re-use buffer |
394 | | - (let ((name python-pytest-buffer-name)) |
395 | | - (when python-pytest-project-name-in-buffer-name |
396 | | - (setq name (format "%s<%s>" name (python-pytest--project-name)))) |
397 | | - (get-buffer-create name))))) |
| 389 | + (if (eq major-mode 'python-pytest-mode) |
| 390 | + (current-buffer) ;; re-use buffer |
| 391 | + (let ((name python-pytest-buffer-name)) |
| 392 | + (when python-pytest-project-name-in-buffer-name |
| 393 | + (setq name (format "%s<%s>" name (python-pytest--project-name)))) |
| 394 | + (get-buffer-create name)))) |
398 | 395 |
|
399 | 396 | (defun python-pytest--process-sentinel (proc _state) |
400 | 397 | "Process sentinel helper to run hooks after PROC finishes." |
@@ -429,10 +426,15 @@ When present ON-REPLACEMENT is substituted, else OFF-REPLACEMENT is appended." |
429 | 426 | (format "%s %s" option it))) |
430 | 427 | args)) |
431 | 428 |
|
432 | | -(defun python-pytest--choose-traceback-style (prompt _value) |
433 | | - "Helper to choose a pytest traceback style using PROMPT." |
434 | | - (completing-read |
435 | | - prompt '("long" "short" "line" "native" "no") nil t)) |
| 429 | +(transient-define-argument python-pytest-dispatch:--tb () |
| 430 | + :description "traceback style" |
| 431 | + :class 'transient-option |
| 432 | + :key "=t" |
| 433 | + :argument "--tb=" |
| 434 | + :choices '("long" "short" "line" "native" "no")) |
| 435 | + |
| 436 | +(defun python-pytest-arguments () |
| 437 | + (transient-args 'python-pytest-dispatch)) |
436 | 438 |
|
437 | 439 |
|
438 | 440 | ;; python helpers |
|
0 commit comments