Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

renaming file, and adding installation instructions

  • Loading branch information...
commit 58831abd3a9d82495d3b6b99437c6aa4d45740f1 1 parent ae24cda
Javier Mansilla jmansilla authored

Showing 1 changed file with 104 additions and 0 deletions. Show diff stats Hide diff stats

  1. +104 0 README.txt
104 README.txt
... ... @@ -0,0 +1,104 @@
  1 +Django test autocompletion
  2 +==========================
  3 +
  4 +This package provides a helpfull way to run specific tests within your project.
  5 +
  6 +Agilizates the invocation of tests to run by providing autocompletion inside
  7 +test modules, listing its TestCases and also tests inside each TestCase.
  8 +
  9 +This first release is a proof-of-concept, and in the "Future features" section
  10 +there is a list of possible improvements considered for next releases.
  11 +
  12 +
  13 +How does it work
  14 +----------------
  15 +
  16 +In order to make a non-intrusive installation, instead of coupling this
  17 +autocompletion with the one provided by Django, we created a proxy command
  18 +named "djntest" which work is to redirect every call to itself to
  19 +"python manage.py test".
  20 +
  21 +Later we defined our customized autocompletion for this new command.
  22 +Autocompletion is defined with a lightweight layer of bash code that it's
  23 +invoked each time the user triggers autocompletion (tipically by hitting the
  24 +<TAB> key). Based on the provided arguments, the bash layer decides to call the
  25 +helper python script get_testcases.py which in turn reads the provided .py
  26 +file, and parse it using the *ast* module.
  27 +
  28 +
  29 +How to use
  30 +----------
  31 +
  32 +Located at the root of your django project, typing:
  33 +
  34 + $ djntest books_application/tests/test_book_creation.py:<TAB>
  35 +
  36 +will list all classes defined in that file, in the standard bash way, ie:
  37 + * if there is only 1 option, it will be automatically completed
  38 + * if all the options at a given time have the same prefix, it's autocompleted
  39 + * if you start typing the name of some TestCase after the colon, hitting <TAB>
  40 + again will filter the offer to only those matching with what you are writting
  41 +
  42 +After a TestCase name, if you a point and trigger autocompletion like this
  43 +
  44 + $ djntest books_application/tests/test_book_creation.py:TestStore.<TAB>
  45 +
  46 +you will see listed all functions defined inside that class which name starts
  47 +with "test_", and again, with all the usual bash autocompletion features.
  48 +
  49 +
  50 +Disclaimer Notes:
  51 +-----------------
  52 +
  53 + * this autocompleter only facilitates the way of invoking the command for
  54 + your running tests. Nothing related with PYTHONPATH is done here.
  55 +
  56 +
  57 +Installation Notes:
  58 +-------------------
  59 +
  60 +In order to install this package you need to follow 2 steps:
  61 +
  62 +1. First install the script
  63 +
  64 + $ sudo pip install django-test-autocomplete
  65 +
  66 +Alternatively, you can install it from the source distribution:
  67 +Extract the tarball and run
  68 +
  69 + $ python setup.py install
  70 +
  71 +2. For enabling the bash autocompletion you need to look for the
  72 +script djntest.sh located in the source distribution, and later:
  73 +
  74 + * load it inside your $HOME/.bashrc adding a line like this:
  75 +
  76 + source path/to/djntest.sh
  77 +
  78 + * copy the file into your bash configuration folder like this:
  79 +
  80 + $ copy path/to/djntest.sh /etc/bash_completion.d/
  81 +
  82 +
  83 +Extra:
  84 +For running tests you will have to install mock package first.
  85 +
  86 +
  87 +Future features:
  88 +----------------
  89 +
  90 + * Improve the python file parsing (done now with ast) for:
  91 + - Detecting if defined clases are TestCases or not
  92 + - Detect tests defined on parent TestCases
  93 + * Clear integration with the usual way of running django tests (ie, avoid the need of
  94 + "proxy" command djntest)
  95 + * Try it out with not-only django projects
  96 + * Support for some other shells (zsh will probably be the next)
  97 +
  98 +
  99 +Tested with:
  100 +------------
  101 + * GNU bash, version 4.2.10
  102 + * Django 1.3
  103 + * I'm using together with django-nose without problems. I see no reason for
  104 + have it not working without nose

0 comments on commit 58831ab

Please sign in to comment.
Something went wrong with that request. Please try again.