• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.10.1/pyobjc-45/pyobjc/pyobjc-core-2.5.1/Doc/sphinx_build/html/_sources/lib/
1=================================================
2:mod:`PyObjCTools.TestSupport` -- Testing helpers
3=================================================
4
5.. module:: PyObjCTools.TestSupport
6   :synopsis: Testing helpers
7
8This module provides classes and functions that are
9usefull for testing PyObjC itself including the framework
10wrappers.
11
12.. warning::
13
14   This module is primarily used for testing PyObjC 
15   and the API isn't fully stable.
16
17
18.. function:: sdkForPython()
19
20   Returns the SDK version used to compile Python,
21   or :data:`None` when no version can be calculated.
22
23   The SDK version is a tupel with the major
24   and minor versions of Mac OS X (for example ``(10, 8)``).
25
26.. function:: fourcc(value)
27
28   Returns the integer value of a four character code
29   "literal".
30
31   The *value* is a byte string of length 4 and contains
32   the contents of the :c:type:`char` C literal with 
33   the four character code, for example ``b"abcd"``.
34
35.. function:: cast_int(value)
36
37   Return *value* as if it were a 4 byte integer (using
38   the overflow behavior of most CPUs)
39
40.. function:: cast_longlong(value)
41
42   Return *value* as if it were a 8 byte integer (using
43   the overflow behavior of most CPUs)
44
45
46.. function:: cast_uint(value)
47
48   Return *value* as if it were a 4 byte unsigned integer (
49   using the overflow behavior of C)
50
51.. function:: cast_ulonglong(value)
52
53   Return *value* as if it were a 8 byte unsigned integer (using
54   the overflow behavior of C)
55
56.. function:: os_release()
57
58   Returns the major release of Mac OS X on the current machine,
59   for example "10.5" on all systems running a version 
60   of Leopard.
61
62.. function:: is32Bit()
63
64   Returns :data:`True` if the proces is in 32-bit mode.
65
66.. function:: onlyIf(expr, message)
67
68   Decorator for enabling tests only when an expression is true. This is
69   the same as :func:`skipUnless <unittest.skipUnless>` in Python 2.7 or later.
70
71.. function:: onlyPython2
72
73   Decorator for enabling a test only when using Python 2.x.
74
75   This is basicly ``onlyIf(sys.version_info[0] == 2)``.
76
77.. function:: onlyPython3
78
79   Decorator for enabling a test only when using Python 3.x.
80
81   This is basicly ``onlyIf(sys.version_info[0] == 3)``.
82
83.. function:: onlyOn32Bit
84
85   Decorator for enabling a test only when the process is running in 32-bit mode.
86
87.. function:: onlyOn64Bit
88
89   Decorator for enabling a test only when the process is running in 64-bit mode.
90
91.. function:: min_os_level(version)
92
93   Decorator for enabling a test only when running on a recent enough release
94   of Mac OS X.
95
96
97.. function:: max_os_level(version)
98
99   Decorator for enabling a test only when running on a old enough release
100   of Mac OS X.
101
102.. class:: filterWarnings(kind, category)
103
104   A with-statement context that adds a filter to the warnings module
105   while the body of the statement is running.
106
107   This is similar to :class:`warnings.catch_warnings`.
108
109.. class:: TestCase
110
111   A subclass of :class:`unittest.TestCase` with some addition functionality. The
112   most important addition is that each test gets run with a fresh autorelease pool.
113
114   .. method:: assertItemsEqual(seq1, seq2[, message])
115
116      Asserts that sequences *seq1* and *seq2* have the same members (in any order).
117
118   .. method:: assertGreaterThan(value, test[, message])
119
120      Asserts that *value* is greater than *test*.
121
122   .. method:: assertGreaterThanOrEquals(value, test[, message])
123
124      Asserts that *value* is greater than or equal to *test*.
125
126   .. method:: assertLessThan(value, test[, message])
127
128      Asserts that *value* is less than *test*.
129
130   .. method:: assertLessThanOrEquals(value, test[, message])
131
132      Asserts that *value* is less than or equal to *test*.
133
134   .. method:: assertIs(value, test[, message])
135
136      Asserts that *value* is the same object as *test*
137
138   .. method:: assertIsNot(value, test[, message])
139
140      Asserts that *value* is not the same object as *test*
141
142   .. method:: assertIsNone(value[, message])
143
144      Asserts that *value* is the same object as :data:`None`
145
146   .. method:: assertIsNotNone(value[, message])
147
148      Asserts that *value* is the not same object as :data:`None`
149
150   .. method:: assertSstartswith(self, value, check[, message])
151
152      Assert that *value* is a string that starts with *check*.
153
154   .. method:: assertHasAttr(self, value, key[, message])
155
156      Assert that *value* has an attribute named *key*.
157
158   .. method:: assertNotHasAttr(self, value, key[, message])
159
160      Assert that *value* does not have an attribute named *key*.
161
162   .. method:: assertIsInstance(self, value, types[, message])
163
164      Assert that *value* is an instance of *types*.
165
166   .. method:: assertIsNotInstance(self, value, types[, message])
167
168      Assert that *value* is not an instance of *types*.
169
170   .. method:: assertAlmostEquals(val1, val2[, message)
171
172      Assert that *val1* is almost equal to *val2* (that is,
173      the difference between the two values is less that 1e-5)
174
175   .. method:: assertIn(self, value, seq[, message])
176
177      Assert that *value* is a member of *seq*.
178
179   .. method:: assertNotIn(self, value, seq[, message])
180
181      Assert that *value* is not a member of *seq*.
182
183   .. method:: assertIsCFType(tp[, message])
184
185      Asserts that *tp* is a wrapper class for a CoreFoundation type.
186
187   .. method:: assertIsOpaquePointer(tp[, message)
188
189      Asserts that *tp* is a wrapper class for an opaque pointer ("handle")
190
191   .. method:: assertIsNullTerminated(method[, message])
192
193      Asserts that the callable has metadata that indicates that the 
194      callable is variadic function where the argument list is terminated by
195      a null value.
196
197   .. method:: assertResultIsNullTerminated(method[, message])
198
199      Asserts that the callable has metadata that indicates that the result
200      is a null terminated array.
201
202   .. method:: assertArgIsNullTerminated(method, argno[, message])
203
204      Asserts that the callable has metadata that indicates that the argument
205      *argno* is a null terminated array.
206
207
208   .. method:: assertResultIsVariableSize(method[, message])
209
210      Asserts that the callable has metadata that indicates that the result
211      is an array with an unspecified size.
212
213   .. method:: assertArgIsVariableSize(method, argno[, message])
214
215      Asserts that the callable has metadata that indicates that the argument
216      *argno* is an array with an unspecified size.
217
218   .. method:: assertArgSizeInResult(method, argno[, message)
219      Asserts that the callable has metadata that indicates that the argument
220      *argno* is an array where the size of the array is specified in the return value.
221
222   .. method:: assertArgIsPrintf(method, argno[, message])
223
224      Assert that the callable has metadata that specifies that it is a
225      variadic function with a printf-format string in argument *argno*.
226
227   .. method:: assertResultIsCFRetained(method[, message])
228
229      Assert that the callable has metadata that specifies that the
230      retain count of the result is increased by the function (that
231      is, the caller owns the value after the call).
232
233   .. method:: assertResultIsNotCFRetained(method[, message])
234
235      Assert that the callable has metadata that specifies that the
236      retain count of the result is not increased by the function.
237
238   .. method:: assertArgIsCFRetained(method, argno[, message])
239
240      Assert that the callable has metadata that specifies that the
241      retain count of argument *argno* is increased by the function (that
242      is, the caller owns the value after the call).
243
244      .. note:: used to check the behavior of output arguments.
245
246   .. method:: assertArgIsNotCFRetained(method, argno[, message])
247
248      Assert that the callable has metadata that specifies that the
249      retain count of argument *argno* is not increased by the function.
250
251      .. note:: used to check the behavior of output arguments.
252
253   .. method:: assertResultIsRetained(method[, message])
254
255      Assert that the callable has metadata that specifies that the
256      retain count of the result is increased by the function (that
257      is, the caller owns the value after the call).
258
259   .. method:: assertResultIsNotRetained(method[, message])
260
261      Assert that the callable has metadata that specifies that the
262      retain count of the result is not increased by the function.
263
264   .. method:: assertArgIsRetained(method, argno[, message])
265
266      Assert that the callable has metadata that specifies that the
267      retain count of argument *argno* is increased by the function (that
268      is, the caller owns the value after the call).
269
270      .. note:: used to check the behavior of output arguments.
271
272   .. method:: assertArgIsNotRetained(method, argno[, message])
273
274      Assert that the callable has metadata that specifies that the
275      retain count of argument *argno* is not increased by the function.
276
277      .. note:: used to check the behavior of output arguments.
278
279   .. method:: assertResultHasType(method, tp[, message])
280
281      Assert that the result has a specific type encoding.
282
283   .. method:: assertResultIsBOOL(method[, message])
284
285      Assert that the result has type :c:type:`BOOL`.
286
287   .. method:: assertArgHasType(method, argno, tp[, message])
288
289      Assert that the argument *argno* has a specific type encoding.
290
291   .. method:: assertArgIsBOOL(method, argno[, message])
292
293      Assert that the argument *argno* has type :c:type:`BOOL`.
294
295   .. method:: assertArgIsFunction(method, argno, sel_type, retained[, message])
296
297      Assert that argument *argno* is a function with a specific type signature.
298      If *retained* is true the function stores the function reference beyond
299      the end of the function call.
300
301   .. method:: assertResultIsBlock(method, sel_type[, message])
302
303      Assert that the result is a block with a specific type signature.
304
305   .. method:: assertArgIsBlock(method, argno, sel_type[, message])
306
307      Assert that argument *argno* is a block with a specific type signature.
308
309   .. method:: assertArgIsSEL(method, argno, sel_type[, message])
310
311      Assert that argument *argno* is a SEL value for a method with
312      a specific type signature
313
314   .. method:: assertArgIsFixedSize(method, argno, count[, message])
315
316      Assert that argument *argno* is an array of *count* elements.
317
318   .. method:: assertResultSizeInArg(method, count[, message])
319
320      Assert that the result is an array of where the size
321      of the array is specified in argument *count*.
322
323   .. method:: assertArgSizeInArg(method, argno, count[, message])
324
325      Assert that argument *argno* is an array of where the size
326      of the array is specified in argument *count*.
327
328      *count* can also be an tuple of two elements: the first elements
329      specifies the size before the call, the second the size
330      after the call. 
331
332   .. method:: assertArgIsOut(method, argno[, message])
333
334      Assert that argument *argno* is a pass-by-reference output parameter.
335
336   .. method:: assertArgIsIn(method, argno[, message])
337
338      Assert that argument *argno* is a pass-by-reference input parameter.
339
340   .. method:: assertArgIsInOut(method, argno[, message])
341
342      Assert that argument *argno* is a pass-by-reference input and output parameter.
343
344   .. note::
345
346      There are also a number of deprecated aliases for the methods above, those
347      are intentionally not documented.
348