Codebase list pyhamcrest / bec0e30
removing upstream egg David Villa Alises 11 years ago
4 changed file(s) with 412 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 pyhamcrest (1.6-3) unstable; urgency=low
1
2 * debian/patches/remove-egg.diff to remove upstream egg (Closes: #671190)
3 * debian/ mergeWithUpstream svn property typo fixed
4
5 -- David Villa Alises <David.Villa@uclm.es> Mon, 02 Apr 2012 01:13:03 +0200
6
07 pyhamcrest (1.6-2) unstable; urgency=low
18
29 * debian/watch changed to code.google.com URL
0 --- a/PyHamcrest.egg-info/PKG-INFO
1 +++ /dev/null
2 @@ -1,270 +0,0 @@
3 -Metadata-Version: 1.1
4 -Name: PyHamcrest
5 -Version: 1.6
6 -Summary: Hamcrest framework for matcher objects
7 -Home-page: http://code.google.com/p/hamcrest/
8 -Author: Jon Reid
9 -Author-email: jon.reid@mac.com
10 -License: New BSD
11 -Download-URL: http://pypi.python.org/packages/source/P/PyHamcrest/PyHamcrest-1.6.tar.gz
12 -Description: * [Full documentation](http://packages.python.org/PyHamcrest)
13 - * [Latest package](http://pypi.python.org/pypi/PyHamcrest)
14 - * [Latest sources](https://github.com/jonreid/PyHamcrest)
15 - * [Hamcrest information](http://code.google.com/p/hamcrest)
16 -
17 - See also:
18 -
19 - * [OCHamcrest](https://github.com/jonreid/OCHamcrest) - Objective-C version for
20 - Cocoa and iOS.
21 - * [Quality Coding](http://jonreid.blogs.com/qualitycoding/) - Tools, tips and
22 - techniques for _building quality in_ to your iOS programs.
23 -
24 -
25 - Introduction
26 - ============
27 -
28 - PyHamcrest is a framework for writing matcher objects, allowing you to
29 - declaratively define "match" rules. There are a number of situations where
30 - matchers are invaluable, such as UI validation, or data filtering, but it is in
31 - the area of writing flexible tests that matchers are most commonly used. This
32 - tutorial shows you how to use PyHamcrest for unit testing.
33 -
34 - When writing tests it is sometimes difficult to get the balance right between
35 - overspecifying the test (and making it brittle to changes), and not specifying
36 - enough (making the test less valuable since it continues to pass even when the
37 - thing being tested is broken). Having a tool that allows you to pick out
38 - precisely the aspect under test and describe the values it should have, to a
39 - controlled level of precision, helps greatly in writing tests that are "just
40 - right." Such tests fail when the behavior of the aspect under test deviates
41 - from the expected behavior, yet continue to pass when minor, unrelated changes
42 - to the behaviour are made.
43 -
44 - Installation
45 - ============
46 -
47 - Hamcrest can be installed using the usual Python packaging tools. It depends on
48 - distribute, but as long as you have a network connection when you install, the
49 - installation process will take care of that for you.
50 -
51 - My first PyHamcrest test
52 - ========================
53 -
54 - We'll start by writing a very simple PyUnit test, but instead of using PyUnit's
55 - ``assertEqual`` method, we'll use PyHamcrest's ``assert_that`` construct and
56 - the standard set of matchers::
57 -
58 - from hamcrest import *
59 - import unittest
60 -
61 - class BiscuitTest(unittest.TestCase):
62 - def testEquals(self):
63 - theBiscuit = Biscuit('Ginger')
64 - myBiscuit = Biscuit('Ginger')
65 - assert_that(theBiscuit, equal_to(myBiscuit))
66 -
67 - if __name__ == '__main__':
68 - unittest.main()
69 -
70 - The ``assert_that`` function is a stylized sentence for making a test
71 - assertion. In this example, the subject of the assertion is the object
72 - ``theBiscuit``, which is the first method parameter. The second method
73 - parameter is a matcher for ``Biscuit`` objects, here a matcher that checks one
74 - object is equal to another using the Python ``==`` operator. The test passes
75 - since the ``Biscuit`` class defines an ``__eq__`` method.
76 -
77 - If you have more than one assertion in your test you can include an identifier
78 - for the tested value in the assertion::
79 -
80 - assert_that(theBiscuit.getChocolateChipCount(), equal_to(10), 'chocolate chips')
81 - assert_that(theBiscuit.getHazelnutCount(), equal_to(3), 'hazelnuts')
82 -
83 - As a convenience, assert_that can also be used to verify a boolean condition::
84 -
85 - assert_that(theBiscuit.isCooked(), 'cooked')
86 -
87 - This is equivalent to the ``assert_`` method of unittest.TestCase, but because
88 - it's a standalone function, it offers greater flexibility in test writing.
89 -
90 -
91 - Predefined matchers
92 - ===================
93 -
94 - PyHamcrest comes with a library of useful matchers:
95 -
96 - * Object
97 -
98 - * ``equal_to`` - match equal object
99 - * ``has_length`` - match ``len()``
100 - * ``has_property`` - match value of property with given name
101 - * ``has_string`` - match ``str()``
102 - * ``instance_of`` - match object type
103 - * ``none``, ``not_none`` - match ``None``, or not ``None``
104 - * ``same_instance`` - match same object
105 -
106 - * Number
107 -
108 - * ``close_to`` - match number close to a given value
109 - * ``greater_than``, ``greater_than_or_equal_to``, ``less_than``,
110 - ``less_than_or_equal_to`` - match numeric ordering
111 -
112 - * Text
113 -
114 - * ``contains_string`` - match part of a string
115 - * ``ends_with`` - match the end of a string
116 - * ``equal_to_ignoring_case`` - match the complete string but ignore case
117 - * ``equal_to_ignoring_whitespace`` - match the complete string but ignore
118 - extra whitespace
119 - * ``starts_with`` - match the beginning of a string
120 - * ``string_contains_in_order`` - match parts of a string, in relative order
121 -
122 - * Logical
123 -
124 - * ``all_of`` - ``and`` together all matchers
125 - * ``any_of`` - ``or`` together all matchers
126 - * ``anything`` - match anything, useful in composite matchers when you don't
127 - care about a particular value
128 - * ``is_not`` - negate the matcher
129 -
130 - * Sequence
131 -
132 - * ``contains`` - exactly match the entire sequence
133 - * ``contains_inanyorder`` - match the entire sequence, but in any order
134 - * ``has_item`` - match if given item appears in the sequence
135 - * ``has_items`` - match if all given items appear in the sequence, in any
136 - order
137 - * ``is_in`` - match if item appears in the given sequence
138 - * ``only_contains`` - match if sequence's items appear in given list
139 -
140 - * Dictionary
141 -
142 - * ``has_entries`` - match dictionary with list of key-value pairs
143 - * ``has_entry`` - match dictionary containing a key-value pair
144 - * ``has_key`` - match dictionary with a key
145 - * ``has_value`` - match dictionary with a value
146 -
147 - * Decorator
148 -
149 - * ``described_as`` - give the matcher a custom failure description
150 - * ``is_`` - decorator to improve readability - see `Syntactic sugar` below
151 -
152 - The arguments for many of these matchers accept not just a matching value, but
153 - another matcher, so matchers can be composed for greater flexibility. For
154 - example, ``only_contains(less_than(5))`` will match any sequence where every
155 - item is less than 5.
156 -
157 -
158 - Syntactic sugar
159 - ===============
160 -
161 - PyHamcrest strives to make your tests as readable as possible. For example, the
162 - ``is_`` matcher is a wrapper that doesn't add any extra behavior to the
163 - underlying matcher. The following assertions are all equivalent::
164 -
165 - assert_that(theBiscuit, equal_to(myBiscuit))
166 - assert_that(theBiscuit, is_(equal_to(myBiscuit)))
167 - assert_that(theBiscuit, is_(myBiscuit))
168 -
169 - The last form is allowed since ``is_(value)`` wraps most non-matcher arguments
170 - with ``equal_to``. But if the argument is a type, it is wrapped with
171 - ``instance_of``, so the following are also equivalent::
172 -
173 - assert_that(theBiscuit, instance_of(Biscuit))
174 - assert_that(theBiscuit, is_(instance_of(Biscuit)))
175 - assert_that(theBiscuit, is_(Biscuit))
176 -
177 - *Note that PyHamcrest's ``is_`` matcher is unrelated to Python's ``is``
178 - operator. The matcher for object identity is ``same_instance``.*
179 -
180 -
181 - Writing custom matchers
182 - =======================
183 -
184 - PyHamcrest comes bundled with lots of useful matchers, but you'll probably find
185 - that you need to create your own from time to time to fit your testing needs.
186 - This commonly occurs when you find a fragment of code that tests the same set
187 - of properties over and over again (and in different tests), and you want to
188 - bundle the fragment into a single assertion. By writing your own matcher you'll
189 - eliminate code duplication and make your tests more readable!
190 -
191 - Let's write our own matcher for testing if a calendar date falls on a Saturday.
192 - This is the test we want to write::
193 -
194 - def testDateIsOnASaturday(self):
195 - d = datetime.date(2008, 04, 26)
196 - assert_that(d, is_(on_a_saturday()))
197 -
198 - And here's the implementation::
199 -
200 - from hamcrest.core.base_matcher import BaseMatcher
201 - from hamcrest.core.helpers.hasmethod import hasmethod
202 -
203 - class IsGivenDayOfWeek(BaseMatcher):
204 -
205 - def __init__(self, day):
206 - self.day = day # Monday is 0, Sunday is 6
207 -
208 - def _matches(self, item):
209 - if not hasmethod(item, 'weekday'):
210 - return False
211 - return item.weekday() == self.day
212 -
213 - def describe_to(self, description):
214 - day_as_string = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
215 - 'Friday', 'Saturday', 'Sunday']
216 - description.append_text('calendar date falling on ') \
217 - .append_text(day_as_string[self.day])
218 -
219 - def on_a_saturday():
220 - return IsGivenDayOfWeek(5)
221 -
222 - For our Matcher implementation we implement the ``_matches`` method - which
223 - calls the ``weekday`` method after confirming that the argument (which may not
224 - be a date) has such a method - and the ``describe_to`` method - which is used
225 - to produce a failure message when a test fails. Here's an example of how the
226 - failure message looks::
227 -
228 - assert_that(datetime.date(2008, 04, 06), is_(on_a_saturday()))
229 -
230 - fails with the message::
231 -
232 - AssertionError:
233 - Expected: is calendar date falling on Saturday
234 - got: <2008-04-06>
235 -
236 - Let's say this matcher is saved in a module named ``isgivendayofweek``. We
237 - could use it in our test by importing the factory function ``on_a_saturday``::
238 -
239 - from hamcrest import *
240 - import unittest
241 - from isgivendayofweek import on_a_saturday
242 -
243 - class DateTest(unittest.TestCase):
244 - def testDateIsOnASaturday(self):
245 - d = datetime.date(2008, 04, 26)
246 - assert_that(d, is_(on_a_saturday()))
247 -
248 - if __name__ == '__main__':
249 - unittest.main()
250 -
251 - Even though the ``on_a_saturday`` function creates a new matcher each time it
252 - is called, you should not assume this is the only usage pattern for your
253 - matcher. Therefore you should make sure your matcher is stateless, so a single
254 - instance can be reused between matches.
255 -
256 -Keywords: hamcrest matchers pyunit unit test testing unittest unittesting
257 -Platform: All
258 -Classifier: Development Status :: 5 - Production/Stable
259 -Classifier: Environment :: Console
260 -Classifier: Intended Audience :: Developers
261 -Classifier: License :: OSI Approved :: BSD License
262 -Classifier: Natural Language :: English
263 -Classifier: Operating System :: OS Independent
264 -Classifier: Programming Language :: Python :: 2.5
265 -Classifier: Programming Language :: Python :: 2.6
266 -Classifier: Programming Language :: Python :: 2.7
267 -Classifier: Programming Language :: Python :: 3.1
268 -Classifier: Programming Language :: Python :: 3.2
269 -Classifier: Topic :: Software Development
270 -Classifier: Topic :: Software Development :: Quality Assurance
271 -Classifier: Topic :: Software Development :: Testing
272 -Provides: hamcrest
273 --- a/PyHamcrest.egg-info/SOURCES.txt
274 +++ /dev/null
275 @@ -1,112 +0,0 @@
276 -CHANGES.txt
277 -LICENSE.txt
278 -MANIFEST.in
279 -README.md
280 -setup.cfg
281 -setup.py
282 -PyHamcrest.egg-info/PKG-INFO
283 -PyHamcrest.egg-info/SOURCES.txt
284 -PyHamcrest.egg-info/dependency_links.txt
285 -PyHamcrest.egg-info/requires.txt
286 -PyHamcrest.egg-info/top_level.txt
287 -examples/CustomDateMatcher.py
288 -examples/ExampleWithAssertThat.py
289 -hamcrest/__init__.py
290 -hamcrest/core/__init__.py
291 -hamcrest/core/assert_that.py
292 -hamcrest/core/base_description.py
293 -hamcrest/core/base_matcher.py
294 -hamcrest/core/description.py
295 -hamcrest/core/matcher.py
296 -hamcrest/core/selfdescribing.py
297 -hamcrest/core/selfdescribingvalue.py
298 -hamcrest/core/string_description.py
299 -hamcrest/core/core/__init__.py
300 -hamcrest/core/core/allof.py
301 -hamcrest/core/core/anyof.py
302 -hamcrest/core/core/described_as.py
303 -hamcrest/core/core/is_.py
304 -hamcrest/core/core/isanything.py
305 -hamcrest/core/core/isequal.py
306 -hamcrest/core/core/isinstanceof.py
307 -hamcrest/core/core/isnone.py
308 -hamcrest/core/core/isnot.py
309 -hamcrest/core/core/issame.py
310 -hamcrest/core/helpers/__init__.py
311 -hamcrest/core/helpers/hasmethod.py
312 -hamcrest/core/helpers/wrap_matcher.py
313 -hamcrest/library/__init__.py
314 -hamcrest/library/collection/__init__.py
315 -hamcrest/library/collection/isdict_containing.py
316 -hamcrest/library/collection/isdict_containingentries.py
317 -hamcrest/library/collection/isdict_containingkey.py
318 -hamcrest/library/collection/isdict_containingvalue.py
319 -hamcrest/library/collection/isin.py
320 -hamcrest/library/collection/issequence_containing.py
321 -hamcrest/library/collection/issequence_containinginanyorder.py
322 -hamcrest/library/collection/issequence_containinginorder.py
323 -hamcrest/library/collection/issequence_onlycontaining.py
324 -hamcrest/library/integration/__init__.py
325 -hamcrest/library/integration/match_equality.py
326 -hamcrest/library/number/__init__.py
327 -hamcrest/library/number/iscloseto.py
328 -hamcrest/library/number/ordering_comparison.py
329 -hamcrest/library/object/__init__.py
330 -hamcrest/library/object/haslength.py
331 -hamcrest/library/object/hasproperty.py
332 -hamcrest/library/object/hasstring.py
333 -hamcrest/library/text/__init__.py
334 -hamcrest/library/text/isequal_ignoring_case.py
335 -hamcrest/library/text/isequal_ignoring_whitespace.py
336 -hamcrest/library/text/stringcontains.py
337 -hamcrest/library/text/stringcontainsinorder.py
338 -hamcrest/library/text/stringendswith.py
339 -hamcrest/library/text/stringstartswith.py
340 -hamcrest/library/text/substringmatcher.py
341 -hamcrest_unit_test/__init__.py
342 -hamcrest_unit_test/alltests.py
343 -hamcrest_unit_test/assert_that_test.py
344 -hamcrest_unit_test/base_matcher_test.py
345 -hamcrest_unit_test/matcher_test.py
346 -hamcrest_unit_test/object_import.py
347 -hamcrest_unit_test/string_description_test.py
348 -hamcrest_unit_test/collection/__init__.py
349 -hamcrest_unit_test/collection/isdict_containing_test.py
350 -hamcrest_unit_test/collection/isdict_containingentries_test.py
351 -hamcrest_unit_test/collection/isdict_containingkey_test.py
352 -hamcrest_unit_test/collection/isdict_containingvalue_test.py
353 -hamcrest_unit_test/collection/isin_test.py
354 -hamcrest_unit_test/collection/issequence_containing_test.py
355 -hamcrest_unit_test/collection/issequence_containinginanyorder_test.py
356 -hamcrest_unit_test/collection/issequence_containinginorder_test.py
357 -hamcrest_unit_test/collection/issequence_onlycontaining_test.py
358 -hamcrest_unit_test/collection/quasidict.py
359 -hamcrest_unit_test/collection/quasisequence.py
360 -hamcrest_unit_test/core/__init__.py
361 -hamcrest_unit_test/core/allof_test.py
362 -hamcrest_unit_test/core/anyof_test.py
363 -hamcrest_unit_test/core/described_as_test.py
364 -hamcrest_unit_test/core/is_test.py
365 -hamcrest_unit_test/core/isanything_test.py
366 -hamcrest_unit_test/core/isequal_test.py
367 -hamcrest_unit_test/core/isinstanceof_test.py
368 -hamcrest_unit_test/core/isnone_test.py
369 -hamcrest_unit_test/core/isnot_test.py
370 -hamcrest_unit_test/core/issame_test.py
371 -hamcrest_unit_test/core/nevermatch.py
372 -hamcrest_unit_test/integration/__init__.py
373 -hamcrest_unit_test/integration/match_equality_test.py
374 -hamcrest_unit_test/number/__init__.py
375 -hamcrest_unit_test/number/iscloseto_test.py
376 -hamcrest_unit_test/number/ordering_comparison_test.py
377 -hamcrest_unit_test/object/__init__.py
378 -hamcrest_unit_test/object/haslength_test.py
379 -hamcrest_unit_test/object/hasproperty_test.py
380 -hamcrest_unit_test/object/hasstring_test.py
381 -hamcrest_unit_test/text/__init__.py
382 -hamcrest_unit_test/text/isequal_ignoring_case_test.py
383 -hamcrest_unit_test/text/isequal_ignoring_whitespace_test.py
384 -hamcrest_unit_test/text/stringcontains_test.py
385 -hamcrest_unit_test/text/stringcontainsinorder_test.py
386 -hamcrest_unit_test/text/stringendswith_test.py
387 -hamcrest_unit_test/text/stringstartswith_test.py
388 \ No newline at end of file
389 --- a/PyHamcrest.egg-info/dependency_links.txt
390 +++ /dev/null
391 @@ -1 +0,0 @@
392 -
393 --- a/PyHamcrest.egg-info/requires.txt
394 +++ /dev/null
395 @@ -1 +0,0 @@
396 -distribute
397 \ No newline at end of file
398 --- a/PyHamcrest.egg-info/top_level.txt
399 +++ /dev/null
400 @@ -1,2 +0,0 @@
401 -hamcrest_unit_test
402 -hamcrest
0 remove-egg.diff
00 #!/usr/bin/make -f
11
22 %:
3 dh $@ --with python2
3 dh $@ --with python2 --with quilt