diff options
Diffstat (limited to 'tests/test-prog-python--format-wiring.el')
| -rw-r--r-- | tests/test-prog-python--format-wiring.el | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test-prog-python--format-wiring.el b/tests/test-prog-python--format-wiring.el new file mode 100644 index 00000000..67c18dd1 --- /dev/null +++ b/tests/test-prog-python--format-wiring.el @@ -0,0 +1,40 @@ +;;; test-prog-python--format-wiring.el --- Verify the Python formatter is wired -*- lexical-binding: t; -*- + +;;; Commentary: +;; Three checks for the Python formatter: +;; 1. `blacken-buffer' is fboundp after the prog-python config loads. +;; 2. C-; f in `python-ts-mode-map' resolves to `blacken-buffer'. +;; 3. The `black' executable is on PATH (skipped if not installed). + +;;; Code: + +(require 'ert) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(add-to-list 'load-path (expand-file-name "tests" user-emacs-directory)) +(require 'testutil-format-wiring) + +(format-test--ensure-packages-init) +;; use-package's `:bind (:map ...)' defers until the named map exists. +;; Loading python.el populates `python-ts-mode-map'; loading blacken +;; resolves the binding form's late-binding hook. +(ignore-errors (require 'prog-python)) +(require 'python) +(require 'blacken) + +(ert-deftest test-prog-python-format-command-fboundp () + "Normal: `blacken-buffer' is fboundp after the package is loaded." + (should (fboundp 'blacken-buffer))) + +(ert-deftest test-prog-python-format-binding-resolves () + "Normal: C-; f in `python-ts-mode-map' is bound to `blacken-buffer'." + (should (eq 'blacken-buffer + (lookup-key python-ts-mode-map (kbd "C-; f"))))) + +(ert-deftest test-prog-python-format-executable-on-path () + "Boundary: the `black' executable is on PATH (skipped if not installed)." + (format-test--skip-unless-executable "black") + (should (executable-find "black"))) + +(provide 'test-prog-python--format-wiring) +;;; test-prog-python--format-wiring.el ends here |
