|
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 |
|
@@ -119,41 +119,50 @@ When non-nil only ‘test_foo()’ will match, and nothing else."
|
119 | 119 | (fmakunbound 'python-pytest-popup)
|
120 | 120 | (makunbound 'python-pytest-popup)
|
121 | 121 |
|
| 122 | +(transient-define-argument python-pytest-popup:--tb () |
| 123 | + :description "traceback style" |
| 124 | + :class 'transient-option |
| 125 | + :key "=t" |
| 126 | + :argument "--tb=" |
| 127 | + :choices '("long" "short" "line" "native" "no")) |
| 128 | + |
122 | 129 | ;;;###autoload (autoload 'python-pytest-popup "python-pytest" nil t)
|
123 |
| -(magit-define-popup python-pytest-popup |
| 130 | +(define-transient-command python-pytest-popup () |
124 | 131 | "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) |
| 132 | + :man-page "pytest" |
| 133 | + :incompatible '(("--verbose" "--verbose --verbose")) |
| 134 | + :value '("--color") |
| 135 | + ["Switches" |
| 136 | + ("-c" "color" "--color") |
| 137 | + ("-d" "run doctests" "--doctest-modules") |
| 138 | + ("-f" "failed first" "--failed-first") |
| 139 | + ("-l" "show locals" "--showlocals") |
| 140 | + ("-p" "debug on error" "--pdb") |
| 141 | + ("-q" "quiet" "--quiet") |
| 142 | + ("-s" "do not capture output" "--capture=no") |
| 143 | + ("-t" "do not cut tracebacks" "--full-trace") |
| 144 | + ("-v" "verbose" ("-v" "--verbose")) |
| 145 | + ("-w" "very verbose" ("-vv" "--verbose --verbose")) |
| 146 | + ("-x" "exit after first failure" "--exitfirst")] |
| 147 | + ["Options" |
| 148 | + ("=k" "only names matching expression" "-k=") |
| 149 | + ("=m" "only marks matching expression" "-m=") |
| 150 | + (python-pytest-popup:--tb) |
| 151 | + ("=x" "exit after N failures or errors" "--maxfail=")] |
| 152 | + [["Run tests" |
| 153 | + ("t" "Test all" python-pytest) |
| 154 | + ("r" "Repeat last test run" python-pytest-repeat) |
| 155 | + ("x" "Test last-failed" python-pytest-last-failed)] |
| 156 | + ["Run tests for specific files" |
| 157 | + ("f" "Test file (dwifdsafjda;sfjsdla;kfjm)" python-pytest-file-dwim) |
| 158 | + ("F" "Test this file" python-pytest-file) |
| 159 | + ("m" "Test multiple files" python-pytest-files)] |
| 160 | + ["Run tests for current function/class" |
| 161 | + ("d" "Test def/class (dwim)" python-pytest-function-dwim) |
| 162 | + ("D" "Test this def/class" python-pytest-function)]]) |
| 163 | + |
| 164 | +(defun python-pytest-arguments () |
| 165 | + (transient-args 'python-pytest-popup)) |
157 | 166 |
|
158 | 167 | ;;;###autoload
|
159 | 168 | (defun python-pytest (&optional args)
|
@@ -388,13 +397,12 @@ With a prefix ARG, allow editing."
|
388 | 397 |
|
389 | 398 | (defun python-pytest--get-buffer ()
|
390 | 399 | "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))))) |
| 400 | + (if (eq major-mode 'python-pytest-mode) |
| 401 | + (current-buffer) ;; re-use buffer |
| 402 | + (let ((name python-pytest-buffer-name)) |
| 403 | + (when python-pytest-project-name-in-buffer-name |
| 404 | + (setq name (format "%s<%s>" name (python-pytest--project-name)))) |
| 405 | + (get-buffer-create name)))) |
398 | 406 |
|
399 | 407 | (defun python-pytest--process-sentinel (proc _state)
|
400 | 408 | "Process sentinel helper to run hooks after PROC finishes."
|
@@ -429,11 +437,6 @@ When present ON-REPLACEMENT is substituted, else OFF-REPLACEMENT is appended."
|
429 | 437 | (format "%s %s" option it)))
|
430 | 438 | args))
|
431 | 439 |
|
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)) |
436 |
| - |
437 | 440 |
|
438 | 441 | ;; python helpers
|
439 | 442 |
|
|
0 commit comments