Skip to content

bcfurtado/django-test-runner.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-test-runner.el

Quickly execute Django tests.

What it does?

This package provides a function to generate commands to run specific Django tests. Invoke the function anywhere on the python file, and you'll have a test command for that file. When the cursor is at the class or method name, it generates a specific command for it. You can see it in use here.

Motivation

A quick feedback cycle is key for good and efficient development workflow. TDD helps with that, and this package aims to give you the necessary tooling when executing Django tests on Emacs.

Quickstart

Installation

This package is not on melpa yet. If you would like to install it in the meantime and you are using use-package and straight.el, you can:

(use-package django-test-runner
  :straight (:host github
             :repo "bcfurtado/django-test-runner.el"))

(use-package python
  :after (django-test-runner)
  :bind (:map python-mode-map
         ("<f10>" . django-test-runner)))

Otherwise, save django-test-runner.el locally and install transient package. transient is available in melpa.

(load "~/.emacs.d/django-test-runner.el")
(require 'django-test-runner)
(define-key python-mode-map (kbd "<f10>") 'django-test-runner)

Basic Usage

  • On a Django test case, go to a class or method that you want to execute the tests.
  • Invoke django-test-runner function.
  • Choose the proper options on the pop-up. Press RET.
  • Press RET again to accept django-test-runner.el suggestion.

Notes

  • The compile command is always executed with the comint-mode, unless --no-input option is selected. This behavior is required in case manage.py try to interact with you. commint-mode allows you to interact with the subprocess in case you need it.
  • For a better experience, keep the --no-input always enabled and the compile will run without comint-mode. Now you can use compilation-mode keybind like g (recompile), M-g n (next-error) and M-g p (previous-error) on *compilation* buffer.
  • To save your command preferences, e.g. keep --no-input enabled by default, press C-x C-s (transient-save) while the pop-up is open.

Extra tips

  • Compilation mode does not scroll down the buffer window as the output appears by default. If you want this behavior you should:
(setq compilation-scroll-output t)
  • It can be useful to automatically select *compilation* buffer when the command is executed. You can achieve this behavior by advising the compile command.
(defun follow-compilation (&rest args)
  (when (get-buffer "*compilation*")
    (switch-to-buffer-other-window "*compilation*")))

(advice-add 'compile :after follow-compilation)

More information about the Django test options can be found on Django documentation.

License

Distributed under the GNU General Public License, version 3.

About

Quickly execute Django tests

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published