]> git.ozlabs.org Git - patchwork/blob - docs/HACKING
Move to a more recent django project structure
[patchwork] / docs / HACKING
1 == Using virtualenv
2
3 It's always a good idea to use virtualenv to develop python software.
4
5 1. Install pip, virtualenv (python-pip, python-virtualenv packages)
6
7    Because we're going to recompile our dependencies, we'll also need
8    development headers:
9
10    - For the MySQL/MariaDB setups: mariadb-devel (Fedora), libmysqlclient-dev
11      (Debian)
12
13 2. Create a new virtual environement. Virtual environments are "instances" of
14    your system python, without any of the extra python packages installed.
15    Inside a virtual env, we'll just install the dependencies needed for
16    patchwork and run it from there.
17
18    Virtual envs are useful to develop and deploy patchwork against a "well
19    known" set of dependencies. They can also be used to test patchwork against
20    several versions of django, creating a separate virtual env per version.
21
22    $ virtualenv django-1.7
23
24    will create a virtual env called 'django-1.7' in eponymous directory.
25
26 3. Activate a virtual environment
27
28    $ sources django-1.7/bin/activate
29    (django-1.7)$
30
31    The shell prompt is preprended with the virtual env name.
32
33 4. Install the required dependencies
34
35    To ease this task, it's customary to maintain a list of dependencies in a
36    text file and install them in one go. One can maintain such a list of
37    dependencies per interesting configuration.
38
39    (django-1.7)$ pip install -r docs/requirements-django-1.7-mysql.txt
40
41    Of course, this is a one-time step, once installed in the virtual
42    environment, no need to to install the requirements everytime.
43
44 5. Now one can run patchwork within that environment
45
46    (django-1.7)$ ./manage.py --version
47    1.7
48    (django-1.7)$ ./manage.py runserver
49
50 6. To exit the virtual environment
51
52    (django-1.7)$ deactivate
53    $
54
55
56 == Running tests
57
58 - To run all tests:
59
60   $ ./manage.py test
61
62 - To run all test methods (methods which name starts with 'test') of a TestCase
63   subclass:
64
65   $ ./manage.py test patchwork.tests.SubjectCleanUpTest
66
67 - To run a single test:
68
69   $ ./manage.py test patchwork.tests.SubjectCleanUpTest.testSubjectCleanup