Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/gsutil/boto/docs/source/contributing.rst

Issue 12317103: Added gsutil to depot tools (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: added readme Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 ====================
2 Contributing to Boto
3 ====================
4
5
6 Setting Up a Development Environment
7 ====================================
8
9 While not strictly required, it is highly recommended to do development
10 in a virtualenv. You can install virtualenv using pip::
11
12 $ pip install virtualenv
13
14 Once the package is installed, you'll have a ``virtualenv`` command you can
15 use to create a virtual environment::
16
17 $ virtualenv venv
18
19 You can then activate the virtualenv::
20
21 $ . venv/bin/activate
22
23 .. note::
24
25 You may also want to check out virtualenvwrapper_, which is a set of
26 extensions to virtualenv that makes it easy to manage multiple virtual
27 environments.
28
29 A requirements.txt is included with boto which contains all the additional
30 packages needed for boto development. You can install these packages by
31 running::
32
33 $ pip install -r requirements.txt
34
35
36 Running the Tests
37 =================
38
39 All of the tests for boto are under the ``tests/`` directory. The tests for
40 boto have been split into two main categories, unit and integration tests:
41
42 * **unit** - These are tests that do not talk to any AWS services. Anyone
43 should be able to run these tests without have any credentials
44 configured. These are the types of tests that could be run in something
45 like a public CI server. These tests tend to be fast.
46
47 * **integration** - These are tests that will talk to AWS services, and
48 will typically require a boto config file with valid credentials.
49 Due to the nature of these tests, they tend to take a while to run.
50 Also keep in mind anyone who runs these tests will incur any usage
51 fees associated with the various AWS services.
52
53 To run all the unit tests, cd to the ``tests/`` directory and run::
54
55 $ python test.py unit
56
57 You should see output like this::
58
59 $ python test.py unit
60 ................................
61 ----------------------------------------------------------------------
62 Ran 32 tests in 0.075s
63
64 OK
65
66 To run the integration tests, run::
67
68 $ python test.py integration
69
70 Note that running the integration tests may take a while.
71
72 Various integration tests have been tagged with service names to allow
73 you to easily run tests by service type. For example, to run the ec2
74 integration tests you can run::
75
76 $ python test.py -t ec2
77
78 You can specify the ``-t`` argument multiple times. For example, to
79 run the s3 and ec2 tests you can run::
80
81 $ python test.py -t ec2 -t s3
82
83 .. warning::
84
85 In the examples above no top level directory was specified. By default,
86 nose will assume the current working directory, so the above command is
87 equivalent to::
88
89 $ python test.py -t ec2 -t s3 .
90
91 Be sure that you are in the ``tests/`` directory when running the tests,
92 or explicitly specify the top level directory. For example, if you in the
93 root directory of the boto repo, you could run the ec2 and s3 tests by
94 running::
95
96 $ python tests/test.py -t ec2 -t s3 tests/
97
98
99 You can use nose's collect plugin to see what tests are associated with each
100 service tag::
101
102 $ python tests.py -t s3 -t ec2 --with-id --collect -v
103
104
105 Testing Details
106 ---------------
107
108 The ``tests/test.py`` script is a lightweight wrapper around nose_. In
109 general, you should be able to run ``nosetests`` directly instead of
110 ``tests/test.py``. The ``tests/unit`` and ``tests/integration`` args
111 in the commands above were referring to directories. The command line
112 arguments are forwarded to nose when you use ``tests/test.py``. For example,
113 you can run::
114
115 $ python tests/test.py -x -vv tests/unit/cloudformation
116
117 And the ``-x -vv tests/unit/cloudformation`` are forwarded to nose. See
118 the nose_ docs for the supported command line options, or run
119 ``nosetests --help``.
120
121 The only thing that ``tests/test.py`` does before invoking nose is to
122 inject an argument that specifies that any testcase tagged with "notdefault"
123 should not be run. A testcase may be tagged with "notdefault" if the test
124 author does not want everyone to run the tests. In general, there shouldn't be
125 many of these tests, but some reasons a test may be tagged "notdefault"
126 include:
127
128 * An integration test that requires specific credentials.
129 * An interactive test (the S3 MFA tests require you to type in the S/N and
130 code).
131
132 Tagging is done using nose's tagging_ plugin. To summarize, you can tag a
133 specific testcase by setting an attribute on the object. Nose provides
134 an ``attr`` decorator for convenience::
135
136 from nose.plugins.attrib import attr
137
138 @attr('notdefault')
139 def test_s3_mfs():
140 pass
141
142 You can then run these tests be specifying::
143
144 nosetests -a 'notdefault'
145
146 Or you can exclude any tests tagged with 'notdefault' by running::
147
148 nosetests -a '!notdefault'
149
150 Conceptually, ``tests/test.py`` is injecting the "-a !notdefault" arg
151 into nosetests.
152
153
154 Testing Supported Python Versions
155 ==================================
156
157 Boto supports python 2.6 and 2.7. An easy way to verify functionality
158 across multiple python versions is to use tox_. A tox.ini file is included
159 with boto. You can run tox with no args and it will automatically test
160 all supported python versions::
161
162 $ tox
163 GLOB sdist-make: boto/setup.py
164 py26 sdist-reinst: boto/.tox/dist/boto-2.4.1.zip
165 py26 runtests: commands[0]
166 ................................
167 ----------------------------------------------------------------------
168 Ran 32 tests in 0.089s
169
170 OK
171 py27 sdist-reinst: boto/.tox/dist/boto-2.4.1.zip
172 py27 runtests: commands[0]
173 ................................
174 ----------------------------------------------------------------------
175 Ran 32 tests in 0.087s
176
177 OK
178 ____ summary ____
179 py26: commands succeeded
180 py27: commands succeeded
181 congratulations :)
182
183
184 Writing Documentation
185 =====================
186
187 The boto docs use sphinx_ to generate documentation. All of the docs are
188 located in the ``docs/`` directory. To generate the html documentation, cd
189 into the docs directory and run ``make html``::
190
191 $ cd docs
192 $ make html
193
194 The generated documentation will be in the ``docs/build/html`` directory.
195 The source for the documentation is located in ``docs/source`` directory,
196 and uses `restructured text`_ for the markup language.
197
198
199 .. _nose: http://readthedocs.org/docs/nose/en/latest/
200 .. _tagging: http://nose.readthedocs.org/en/latest/plugins/attrib.html
201 .. _tox: http://tox.testrun.org/latest/
202 .. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/
203 .. _sphinx: http://sphinx.pocoo.org/
204 .. _restructured text: http://sphinx.pocoo.org/rest.html
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698