TestCenter Reference
Macros.py
Go to the documentation of this file.
1 from builtins import str
2 
3 # Already ported to Python 3
4 # **InsertLicense** code author="Gereon A. Frey"
5 ## @package TestSupport.Macros
6 ## Adds GoogleTest like methods.
7 # GoogleTest has a set of macros to be used for testing. These methods are all
8 # written in upper case which helps identifying the relevant parts of a test
9 # function. This module add similar methods but note that the piping feature
10 # used in GoogleTest is not available in Python and therefore additional user
11 # information must be appended as method argument. This does not mean a
12 # restriction as piping is used as string concatenation in C++ is way harder
13 # than in Python.
14 #
15 # By default, all macros log an info message if the assertion or expectation succeeds.
16 # This can be disabled for each call of a macro by passing logOnSuccess=False. It can
17 # also be disabled for a single test function by using the TestSupport.Base.MacrosShouldLogOnSuccessDecorator.
18 # And finally it can also be disabled by calling TestSupport.Base.setMacrosShouldLogOnSuccess in
19 # the setUpTestCase() method. It does not have to be reset, because the TestCenter enables
20 # it before each TestCase.
21 
22 # -- system imports ----------------------------------------------------------------------------{{{-
23 # ----------------------------------------------------------------------------------------------}}}-
24 
25 # -- local imports -----------------------------------------------------------------------------{{{-
26 import os
27 
28 import sys
29 
30 from TestSupport.TestHelper import TestHelper, UseStackFrameFromCallerForLogging, CancelTestException
31 
32 # ----------------------------------------------------------------------------------------------}}}-
33 
34 # -- class AssertException ---------------------------------------------------------------------{{{-
35 # @cond
36 ## An exception thrown in the ASSERT_ statements of this module.
37 class AssertException (Exception):
38  # -- def __init__ ----------------------------------------------------------------------------{{{-
39  def __init__ (self, reason):
40  self.__reason = reason
41  # --------------------------------------------------------------------------------------------}}}-
42 
43  # -- def getReason ---------------------------------------------------------------------------{{{-
44  def getReason (self):
45  return repr(self.__reason)
46  # --------------------------------------------------------------------------------------------}}}-
47 
48  # -- def __str__ -----------------------------------------------------------------------------{{{-
49  def __str__ (self):
50  return repr(self.__reason)
51  # --------------------------------------------------------------------------------------------}}}-
52 # @endcond
53 # ----------------------------------------------------------------------------------------------}}}-
54 
55 # -- def ASSERT_TRUE ---------------------------------------------------------------------------{{{-
56 ## Throw exception if given expression does not evaluate to true.
57 # @param expr Expression to be evaluated.
58 # @param msg Message to be printed in case of failure.
59 # @param logOnSuccess Print message in case of success.
60 @UseStackFrameFromCallerForLogging
61 def ASSERT_TRUE (expr, msg=None, logOnSuccess=None):
62  if not Base_verifyTrue(expr, comment = msg, logOnSuccess = logOnSuccess):
63  raise AssertException("Expression does not evaluate to true.")
64 # ----------------------------------------------------------------------------------------------}}}-
65 
66 # -- def EXPECT_TRUE ---------------------------------------------------------------------------{{{-
67 ## Expect given expression to evaluate to true.
68 # @param expr Expression to be evaluated.
69 # @param msg Message to be printed in case of failure.
70 # @param logOnSuccess Print message in case of success.
71 # @return Returns true if expression evaluates to true.
72 @UseStackFrameFromCallerForLogging
73 def EXPECT_TRUE (expr, msg=None, logOnSuccess=None):
74  return Base_verifyTrue(expr, comment = msg, logOnSuccess = logOnSuccess)
75 
76 # ----------------------------------------------------------------------------------------------}}}-
77 
78 # -- def ASSERT_FALSE --------------------------------------------------------------------------{{{-
79 ## Throw exception if given expression does not evaluate to false.
80 # @param expr Expression to be evaluated.
81 # @param msg Message to be printed in case of failure.
82 # @param logOnSuccess Print message in case of success.
83 @UseStackFrameFromCallerForLogging
84 def ASSERT_FALSE (expr, msg=None, logOnSuccess=None):
85  if not Base_verifyFalse(expr, comment = msg, logOnSuccess = logOnSuccess):
86  raise AssertException("Expression does not evaluate to false.")
87 
88 # ----------------------------------------------------------------------------------------------}}}-
89 
90 # -- def EXPECT_FALSE --------------------------------------------------------------------------{{{-
91 ## Expect given expression to evaluate to false.
92 # @param expr Expression that must be false.
93 # @param msg Message to be printed if expression true.
94 # @param logOnSuccess Print message in case of success.
95 # @return True if expression evaluates to false.
96 @UseStackFrameFromCallerForLogging
97 def EXPECT_FALSE (expr, msg=None, logOnSuccess=None):
98  return Base_verifyFalse(expr, comment = msg, logOnSuccess = logOnSuccess)
99 # ----------------------------------------------------------------------------------------------}}}-
100 
101 # -- def ASSERT_EQ -----------------------------------------------------------------------------{{{-
102 ## Throw exception if given values are not equal.
103 # @param expected First value.
104 # @param actual Second value.
105 # @param msg Message to be printed in case of failure.
106 # @param logOnSuccess Print message in case of success.
107 @UseStackFrameFromCallerForLogging
108 def ASSERT_EQ (expected, actual, msg=None, logOnSuccess=None):
109  if not Base_compareEqual(expected, actual, comment = msg, logOnSuccess = logOnSuccess):
110  raise AssertException("Values (%s and %s) are not equal." % (str(expected), str(actual)))
111 # ----------------------------------------------------------------------------------------------}}}-
112 
113 # -- def EXPECT_EQ -----------------------------------------------------------------------------{{{-
114 ## Expect given values to be equal.
115 # @param expected First value.
116 # @param actual Second value.
117 # @param msg Message to be printed in case of failure.
118 # @param logOnSuccess Print message in case of success.
119 # @return Returns true in case of success.
120 @UseStackFrameFromCallerForLogging
121 def EXPECT_EQ (expected, actual, msg=None, logOnSuccess=None):
122  return Base_compareEqual(expected, actual, comment = msg, logOnSuccess = logOnSuccess)
123 # ----------------------------------------------------------------------------------------------}}}-
124 
125 # -- def ASSERT_NE -----------------------------------------------------------------------------{{{-
126 ## Throw exception if given values are equal.
127 # @param expected First value.
128 # @param actual Second value.
129 # @param msg Message to be printed in case of failure.
130 # @param logOnSuccess Print message in case of success.
131 @UseStackFrameFromCallerForLogging
132 def ASSERT_NE (expected, actual, msg=None, logOnSuccess=None):
133  if not Base_compareNotEqual(expected, actual, comment = msg, logOnSuccess = logOnSuccess):
134  raise AssertException("Values (%s and %s) are equal." % (str(expected), str(actual)))
135 # ----------------------------------------------------------------------------------------------}}}-
136 
137 # -- def EXPECT_NE -----------------------------------------------------------------------------{{{-
138 ## Expect given values to be not equal.
139 # @param expected First value.
140 # @param actual Second value.
141 # @param msg Message to be printed in case of failure.
142 # @param logOnSuccess Print message in case of success.
143 # @return Returns true in case of success.
144 @UseStackFrameFromCallerForLogging
145 def EXPECT_NE (expected, actual, msg=None, logOnSuccess=None):
146  return Base_compareNotEqual(expected, actual, comment = msg, logOnSuccess = logOnSuccess)
147 # ----------------------------------------------------------------------------------------------}}}-
148 
149 # -- def ASSERT_GT -----------------------------------------------------------------------------{{{-
150 ## Throw exception if first given value is less than or equal to the
151 # second.
152 # @param a First value.
153 # @param b Second value.
154 # @param msg Message to be printed in case of failure.
155 # @param logOnSuccess Print message in case of success.
156 @UseStackFrameFromCallerForLogging
157 def ASSERT_GT (a, b, msg=None, logOnSuccess=None):
158  if not Base_compareLessThan(b, a, comment = msg, logOnSuccess = logOnSuccess):
159  raise AssertException("Value %s not greater than %s." % (str(a), str(b)))
160 # ----------------------------------------------------------------------------------------------}}}-
161 
162 # -- def EXPECT_GT -----------------------------------------------------------------------------{{{-
163 ## Expect first given value to be greater than the second.
164 # @param a First value.
165 # @param b Second value.
166 # @param msg Message to be printed in case of failure.
167 # @param logOnSuccess Print message in case of success.
168 # @return Returns true in case of success.
169 @UseStackFrameFromCallerForLogging
170 def EXPECT_GT (a, b, msg=None, logOnSuccess=None):
171  return Base_compareLessThan(b, a, comment = msg, logOnSuccess = logOnSuccess)
172 # ----------------------------------------------------------------------------------------------}}}-
173 
174 # -- def ASSERT_GE -----------------------------------------------------------------------------{{{-
175 ## Throw exception if first given value is less than the second.
176 # @param a First value.
177 # @param b Second value.
178 # @param msg Message to be printed in case of failure.
179 # @param logOnSuccess Print message in case of success.
180 @UseStackFrameFromCallerForLogging
181 def ASSERT_GE (a, b, msg=None, logOnSuccess=None):
182  if not Base_compareLessThanOrEqual(b, a, comment = msg, logOnSuccess = logOnSuccess):
183  raise AssertException("Value %s not greater than or equal to %s." % (str(a), str(b)))
184 # ----------------------------------------------------------------------------------------------}}}-
185 
186 # -- def EXPECT_GE -----------------------------------------------------------------------------{{{-
187 ## Expect first given value to be greater than or equal to the second.
188 # @param a First value.
189 # @param b Second value.
190 # @param msg Message to be printed in case of failure.
191 # @param logOnSuccess Print message in case of success.
192 # @return Returns true in case of success.
193 @UseStackFrameFromCallerForLogging
194 def EXPECT_GE (a, b, msg=None, logOnSuccess=None):
195  return Base_compareLessThanOrEqual(b, a, comment = msg, logOnSuccess = logOnSuccess)
196 # ----------------------------------------------------------------------------------------------}}}-
197 
198 # -- def ASSERT_LT -----------------------------------------------------------------------------{{{-
199 ## Throw exception if first given value is not less than the second.
200 # @param a First value.
201 # @param b Second value.
202 # @param msg Message to be printed in case of failure.
203 # @param logOnSuccess Print message in case of success.
204 @UseStackFrameFromCallerForLogging
205 def ASSERT_LT (a, b, msg=None, logOnSuccess=None):
206  if not Base_compareLessThan(a, b, comment = msg, logOnSuccess = logOnSuccess):
207  raise AssertException("Value %s not less than %s." % (str(a), str(b)))
208 # ----------------------------------------------------------------------------------------------}}}-
209 
210 # -- def EXPECT_LT -----------------------------------------------------------------------------{{{-
211 ## Expect first given value to be less than the second.
212 # @param a First value.
213 # @param b Second value.
214 # @param msg Message to be printed in case of failure.
215 # @param logOnSuccess Print message in case of success.
216 # @return Returns true in case of success.
217 @UseStackFrameFromCallerForLogging
218 def EXPECT_LT (a, b, msg=None, logOnSuccess=None):
219  return Base_compareLessThan(a, b, comment = msg, logOnSuccess = logOnSuccess)
220 # ----------------------------------------------------------------------------------------------}}}-
221 
222 # -- def ASSERT_LE -----------------------------------------------------------------------------{{{-
223 ## Throw exception if first given value is not less than or equal to the second.
224 # @param a First value.
225 # @param b Second value.
226 # @param msg Message to be printed in case of failure.
227 # @param logOnSuccess Print message in case of success.
228 @UseStackFrameFromCallerForLogging
229 def ASSERT_LE (a, b, msg=None, logOnSuccess=None):
230  if not Base_compareLessThanOrEqual(a, b, comment = msg, logOnSuccess = logOnSuccess):
231  raise AssertException("Value %s not less than or equal to %s." % (str(a), str(b)))
232 # ----------------------------------------------------------------------------------------------}}}-
233 
234 # -- def EXPECT_LE -----------------------------------------------------------------------------{{{-
235 ## Expect first given value to be less than or equal to the second.
236 # @param a First value.
237 # @param b Second value.
238 # @param msg Message to be printed in case of failure.
239 # @param logOnSuccess Print message in case of success.
240 # @return Returns true in case of success.
241 @UseStackFrameFromCallerForLogging
242 def EXPECT_LE (a, b, msg=None, logOnSuccess=None):
243  return Base_compareLessThanOrEqual(a, b, comment = msg, logOnSuccess = logOnSuccess)
244 # ----------------------------------------------------------------------------------------------}}}-
245 
246 # -- def ASSERT_FLOAT_EQ -----------------------------------------------------------------------{{{-
247 ## Throw exception if given values are not equal.
248 # @param expected First value.
249 # @param actual Second value.
250 # @param msg Message to be printed in case of failure.
251 # @param epsilon Epsilon to use for equality check.
252 # @param logOnSuccess Print message in case of success.
253 @UseStackFrameFromCallerForLogging
254 def ASSERT_FLOAT_EQ (expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None):
255  if not Base_compareFloatEqual(expected, actual, msg, epsilon, logOnSuccess):
256  raise AssertException("Values (%s and %s) not equal." % (str(expected), str(actual)))
257 # ----------------------------------------------------------------------------------------------}}}-
258 
259 # -- def EXPECT_FLOAT_EQ -----------------------------------------------------------------------{{{-
260 ## Expect given values to be equal.
261 # @param expected First value.
262 # @param actual Second value.
263 # @param msg Message to be printed in case of failure.
264 # @param epsilon Epsilon to use for equality check.
265 # @param logOnSuccess Print message in case of success.
266 # @return Returns true in case of success.
267 @UseStackFrameFromCallerForLogging
268 def EXPECT_FLOAT_EQ (expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None):
269  return Base_compareFloatEqual(expected, actual, msg, epsilon, logOnSuccess)
270 # ----------------------------------------------------------------------------------------------}}}-
271 
272 # -- def ASSERT_FLOAT_NE -----------------------------------------------------------------------{{{-
273 ## Throw exception if given values are equal.
274 # @param expected First value.
275 # @param actual Second value.
276 # @param msg Message to be printed in case of failure.
277 # @param epsilon Epsilon to use for equality check.
278 # @param logOnSuccess Print message in case of success.
279 @UseStackFrameFromCallerForLogging
280 def ASSERT_FLOAT_NE (expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None):
281  if not Base_compareFloatNotEqual(expected, actual, msg, epsilon, logOnSuccess):
282  raise AssertException("Values (%s and %s) equal." % (str(expected), str(actual)))
283 # ----------------------------------------------------------------------------------------------}}}-
284 
285 # -- def EXPECT_FLOAT_NE -----------------------------------------------------------------------{{{-
286 ## Expect given values to be not equal.
287 # @param expected First value.
288 # @param actual Second value.
289 # @param msg Message to be printed in case of failure.
290 # @param epsilon Epsilon to use for equality check.
291 # @param logOnSuccess Print message in case of success.
292 # @return Returns true in case of success.
293 @UseStackFrameFromCallerForLogging
294 def EXPECT_FLOAT_NE (expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None):
295  return Base_compareFloatNotEqual(expected, actual, msg, epsilon, logOnSuccess)
296 # ----------------------------------------------------------------------------------------------}}}-
297 
298 # -- def ASSERT_FLOAT_GT -----------------------------------------------------------------------{{{-
299 ## Throw exception if first given value is not greater than the second.
300 # @param a First value.
301 # @param b Second value.
302 # @param msg Message to be printed in case of failure.
303 # @param logOnSuccess Print message in case of success.
304 @UseStackFrameFromCallerForLogging
305 def ASSERT_FLOAT_GT (a, b, msg=None, logOnSuccess=None):
306  if not Base_compareFloatLessThan(b, a, comment = msg, logOnSuccess = logOnSuccess):
307  raise AssertException("Value %s not greater than %s." % (str(a), str(b)))
308 # ----------------------------------------------------------------------------------------------}}}-
309 
310 # -- def EXPECT_FLOAT_GT -----------------------------------------------------------------------{{{-
311 ## Expect first given value to be greater than the second.
312 # @param a First value.
313 # @param b Second value.
314 # @param msg Message to be printed in case of failure.
315 # @param logOnSuccess Print message in case of success.
316 # @return Returns true in case of success.
317 @UseStackFrameFromCallerForLogging
318 def EXPECT_FLOAT_GT (a, b, msg=None, logOnSuccess=None):
319  return Base_compareFloatLessThan(b, a, comment = msg, logOnSuccess = logOnSuccess)
320 # ----------------------------------------------------------------------------------------------}}}-
321 
322 # -- def ASSERT_FLOAT_GE -----------------------------------------------------------------------{{{-
323 ## Throw exception if first given value is not greater than or equal to the second.
324 # @param a First value.
325 # @param b Second value.
326 # @param msg Message to be printed in case of failure.
327 # @param epsilon Epsilon to use for equality check.
328 # @param logOnSuccess Print message in case of success.
329 @UseStackFrameFromCallerForLogging
330 def ASSERT_FLOAT_GE (a, b, msg=None, epsilon=0.0001, logOnSuccess=None):
331  if not Base_compareFloatLessThanOrEqual(b, a, msg, epsilon, logOnSuccess):
332  raise AssertException("Value %s not greater than or equal to %s." % (str(a), str(b)))
333 # ----------------------------------------------------------------------------------------------}}}-
334 
335 # -- def EXPECT_FLOAT_GE -----------------------------------------------------------------------{{{-
336 ## Expect first given value to be greater than or equal to the second.
337 # @param a First value.
338 # @param b Second value.
339 # @param msg Message to be printed in case of failure.
340 # @param epsilon Epsilon to use for equality check.
341 # @param logOnSuccess Print message in case of success.
342 # @return Returns true in case of success.
343 @UseStackFrameFromCallerForLogging
344 def EXPECT_FLOAT_GE (a, b, msg=None, epsilon=0.0001, logOnSuccess=None):
345  return Base_compareFloatLessThanOrEqual(b, a, msg, epsilon, logOnSuccess)
346 # ----------------------------------------------------------------------------------------------}}}-
347 
348 # -- def ASSERT_FLOAT_LT -----------------------------------------------------------------------{{{-
349 ## Throw exception if first given value is not less than the second.
350 # @param a First value.
351 # @param b Second value.
352 # @param msg Message to be printed in case of failure.
353 # @param logOnSuccess Print message in case of success.
354 @UseStackFrameFromCallerForLogging
355 def ASSERT_FLOAT_LT (a, b, msg=None, logOnSuccess=None):
356  if not Base_compareFloatLessThan(a, b, comment = msg, logOnSuccess = logOnSuccess):
357  raise AssertException("Value %s not less than %s." % (str(a), str(b)))
358 # ----------------------------------------------------------------------------------------------}}}-
359 
360 # -- def EXPECT_FLOAT_LT -----------------------------------------------------------------------{{{-
361 ## Expect first given value to be less than the second.
362 # @param a First value.
363 # @param b Second value.
364 # @param msg Message to be printed in case of failure.
365 # @param logOnSuccess Print message in case of success.
366 # @return Returns true in case of success.
367 @UseStackFrameFromCallerForLogging
368 def EXPECT_FLOAT_LT (a, b, msg=None, logOnSuccess=None):
369  return Base_compareFloatLessThan(a, b, comment = msg, logOnSuccess = logOnSuccess)
370 # ----------------------------------------------------------------------------------------------}}}-
371 
372 # -- def ASSERT_FLOAT_LE -----------------------------------------------------------------------{{{-
373 ## Throw exception if first given value is not less than or equal to the second.
374 # @param a First value.
375 # @param b Second value.
376 # @param msg Message to be printed in case of failure.
377 # @param epsilon Epsilon to use for equality check.
378 # @param logOnSuccess Print message in case of success.
379 @UseStackFrameFromCallerForLogging
380 def ASSERT_FLOAT_LE (a, b, msg=None, epsilon=0.0001, logOnSuccess=None):
381  if not Base_compareFloatLessThanOrEqual(a, b, msg, epsilon, logOnSuccess):
382  raise AssertException("Value %s not less than or equal to %s." % (str(a), str(b)))
383 # ----------------------------------------------------------------------------------------------}}}-
384 
385 # -- def EXPECT_FLOAT_LE -----------------------------------------------------------------------{{{-
386 ## Expect first given value to be less than or equal to the second.
387 # @param a First value.
388 # @param b Second value.
389 # @param msg Message to be printed in case of failure.
390 # @param epsilon Epsilon to use for equality check.
391 # @param logOnSuccess Print message in case of success.
392 # @return Returns true in case of success.
393 @UseStackFrameFromCallerForLogging
394 def EXPECT_FLOAT_LE (a, b, msg=None, epsilon=0.0001, logOnSuccess=None):
395  return Base_compareFloatLessThanOrEqual(a, b, msg, epsilon, logOnSuccess)
396 # ----------------------------------------------------------------------------------------------}}}-
397 
398 # -- def EXPECT_EMPTY -----------------------------------------------------------------------{{{-
399 ## Expect given container to be empty.
400 # @param a Container.
401 # @param msg Message to be printed in case of failure.
402 # @param logOnSuccess Print message in case of success.
403 # @return Returns true in case of success.
404 @UseStackFrameFromCallerForLogging
405 def EXPECT_EMPTY ( a, msg=None, logOnSuccess=None):
406  return Base_compareEqual( 0, len( a ), comment = msg, logOnSuccess = logOnSuccess )
407 
408 # -- def ASSERT_EMPTY -----------------------------------------------------------------------{{{-
409 ## Throw exception if given container is not empty.
410 # @param a Container.
411 # @param msg Message to be printed in case of failure.
412 # @param logOnSuccess Print message in case of success.
413 @UseStackFrameFromCallerForLogging
414 def ASSERT_EMPTY ( a, msg=None, logOnSuccess=None):
415  if not Base_compareEqual( 0, len( a ), comment = msg, logOnSuccess = logOnSuccess ):
416  raise AssertException( "Container %s is not empty." % (str(a)) )
417 
418 # -- def EXPECT_NOT_EMPTY -----------------------------------------------------------------------{{{-
419 ## Expect given container to be not empty.
420 # @param a Container.
421 # @param msg Message to be printed in case of failure.
422 # @param logOnSuccess Print message in case of success.
423 # @return Returns true in case of success.
424 @UseStackFrameFromCallerForLogging
425 def EXPECT_NOT_EMPTY ( a, msg=None, logOnSuccess=None):
426  return Base_compareLessThan( 0, len( a ), comment = msg, logOnSuccess = logOnSuccess )
427 
428 # -- def ASSERT_NOT_EMPTY -----------------------------------------------------------------------{{{-
429 ## Throw exception if given container is empty.
430 # @param a Container.
431 # @param msg Message to be printed in case of failure.
432 # @param logOnSuccess Print message in case of success.
433 @UseStackFrameFromCallerForLogging
434 def ASSERT_NOT_EMPTY ( a, msg=None, logOnSuccess=None):
435  if not Base_compareLessThan( 0, len( a ), comment = msg, logOnSuccess = logOnSuccess ):
436  raise AssertException( "Container %s is empty." % (str(a)) )
437 
438 # -- def EXPECT_SIZE -----------------------------------------------------------------------{{{-
439 ## Expect given container to have the given size.
440 # @param a Container.
441 # @param size Expected size.
442 # @param msg Message to be printed in case of failure.
443 # @param logOnSuccess Print message in case of success.
444 # @return Returns true in case of success.
445 @UseStackFrameFromCallerForLogging
446 def EXPECT_SIZE ( a, size, msg=None, logOnSuccess=None):
447  return Base_compareEqual( size, len( a ), comment = msg, logOnSuccess = logOnSuccess )
448 
449 # -- def ASSERT_SIZE -----------------------------------------------------------------------{{{-
450 ## Throw exception if given container does not have the given size.
451 # @param a Container.
452 # @param size Expected size.
453 # @param msg Message to be printed in case of failure.
454 # @param logOnSuccess Print message in case of success.
455 @UseStackFrameFromCallerForLogging
456 def ASSERT_SIZE ( a, size, msg=None, logOnSuccess=None):
457  if not Base_compareEqual( size, len( a ), comment = msg, logOnSuccess = logOnSuccess ):
458  raise AssertException( "Container %s size is not %s." % (str(a), str(size)) )
459 
460 # -- def EXPECT_PATH_EXISTS -----------------------------------------------------------------------{{{-
461 ## Expect the given path to exist.
462 # @param path The path to check.
463 # @param msg Message to be printed in case of failure.
464 # @param logOnSuccess Print message in case of success.
465 @UseStackFrameFromCallerForLogging
466 def EXPECT_PATH_EXISTS(path, msg=None, logOnSuccess=None):
467  contextMsg = "Path = %s" % path
468  return Base_verifyTrue(os.path.exists(path), comment = msg, msg=contextMsg, logOnSuccess = logOnSuccess)
469 
470 # -- def EXPECT_PATH_MISSING -----------------------------------------------------------------------{{{-
471 ## Expect the given path to be missing, i.e. it should not exist.
472 # @param path The path to check.
473 # @param msg Message to be printed in case of failure.
474 # @param logOnSuccess Print message in case of success.
475 @UseStackFrameFromCallerForLogging
476 def EXPECT_PATH_MISSING(path, msg=None, logOnSuccess=None):
477  contextMsg = "Path = %s" % path
478  return Base_verifyFalse(os.path.exists(path), comment = msg, msg=contextMsg, logOnSuccess = logOnSuccess)
479 
480 # -- def ASSERT_PATH_EXISTS -----------------------------------------------------------------------{{{-
481 ## Throw exception if given path does not exists.
482 # @param path The path to check.
483 # @param msg Message to be printed in case of failure.
484 # @param logOnSuccess Print message in case of success.
485 @UseStackFrameFromCallerForLogging
486 def ASSERT_PATH_EXISTS(path, msg=None, logOnSuccess=None):
487  contextMsg = "Path = %s" % path
488  if not Base_verifyTrue(os.path.exists(path), comment = msg, msg=contextMsg, logOnSuccess = logOnSuccess):
489  raise AssertException("Path does not exist: %s" % path)
490 
491 # -- def ASSERT_PATH_MISSING -----------------------------------------------------------------------{{{-
492 ## Throw exception if given path is not missing, i.e. if it exists.
493 # @param path The path to check.
494 # @param msg Message to be printed in case of failure.
495 # @param logOnSuccess Print message in case of success.
496 @UseStackFrameFromCallerForLogging
497 def ASSERT_PATH_MISSING(path, msg=None, logOnSuccess=None):
498  contextMsg = "Path = %s" % path
499  if not Base_verifyFalse(os.path.exists(path), comment = msg, msg=contextMsg, logOnSuccess = logOnSuccess):
500  raise AssertException("Path exists: %s" % path)
501 
502 # -- def INFO ----------------------------------------------------------------------------------{{{-
503 ## Create an info message.
504 @UseStackFrameFromCallerForLogging
505 def INFO (msg):
506  Logging_info(msg, depth=1)
507 # ----------------------------------------------------------------------------------------------}}}-
508 
509 # -- def WARNING -------------------------------------------------------------------------------{{{-
510 ## Create a warning message.
511 @UseStackFrameFromCallerForLogging
512 def WARNING (msg):
513  Logging_warning(msg, depth=1)
514 # ----------------------------------------------------------------------------------------------}}}-
515 
516 # -- def ERROR ---------------------------------------------------------------------------------{{{-
517 ## Create an error message.
518 @UseStackFrameFromCallerForLogging
519 def ERROR (msg):
520  Logging_error(msg, depth=1)
521 # ----------------------------------------------------------------------------------------------}}}-
522 
523 # -- def DEBUG_STOP ---------------------------------------------------------------------------------{{{-
524 ## Stops a test immediately for debugging purposes.
525 @UseStackFrameFromCallerForLogging
526 def DEBUG_STOP():
527  Logging_info("Stopping because of DEBUG_STOP()", depth=1)
528  Logging_setStopped(True)
529  raise CancelTestException
530 # ----------------------------------------------------------------------------------------------}}}-
531 
532 from .Base import verifyFalse as Base_verifyFalse, verifyTrue as Base_verifyTrue, \
533  compareEqual as Base_compareEqual, compareNotEqual as Base_compareNotEqual, \
534  compareLessThan as Base_compareLessThan, compareLessThanOrEqual as Base_compareLessThanOrEqual, \
535  compareFloatEqual as Base_compareFloatEqual, compareFloatNotEqual as Base_compareFloatNotEqual, \
536  compareFloatLessThanOrEqual as Base_compareFloatLessThanOrEqual, \
537  compareFloatLessThan as Base_compareFloatLessThan
538 from .Logging import error as Logging_error, warning as Logging_warning, info as Logging_info, setStopped as Logging_setStopped
539 
def EXPECT_NOT_EMPTY
Expect given container to be not empty.
Definition: Macros.py:424
def ASSERT_FLOAT_LT
Throw exception if first given value is not less than the second.
Definition: Macros.py:354
def ASSERT_FLOAT_GT
Throw exception if first given value is not greater than the second.
Definition: Macros.py:304
def ASSERT_PATH_MISSING
Throw exception if given path is not missing, i.e.
Definition: Macros.py:496
def EXPECT_GT
Expect first given value to be greater than the second.
Definition: Macros.py:169
def EXPECT_EQ
Expect given values to be equal.
Definition: Macros.py:120
def EXPECT_FLOAT_GT
Expect first given value to be greater than the second.
Definition: Macros.py:317
def EXPECT_GE
Expect first given value to be greater than or equal to the second.
Definition: Macros.py:193
def EXPECT_PATH_MISSING
Expect the given path to be missing, i.e.
Definition: Macros.py:475
def ASSERT_EQ
Throw exception if given values are not equal.
Definition: Macros.py:107
def ASSERT_LE
Throw exception if first given value is not less than or equal to the second.
Definition: Macros.py:228
def EXPECT_SIZE
Expect given container to have the given size.
Definition: Macros.py:445
def ASSERT_PATH_EXISTS
Throw exception if given path does not exists.
Definition: Macros.py:485
def ASSERT_EMPTY
Throw exception if given container is not empty.
Definition: Macros.py:413
def ASSERT_LT
Throw exception if first given value is not less than the second.
Definition: Macros.py:204
def EXPECT_EMPTY
Expect given container to be empty.
Definition: Macros.py:404
def ASSERT_GT
Throw exception if first given value is less than or equal to the second.
Definition: Macros.py:156
def EXPECT_LT
Expect first given value to be less than the second.
Definition: Macros.py:217
def ASSERT_FLOAT_NE
Throw exception if given values are equal.
Definition: Macros.py:279
def EXPECT_FLOAT_NE
Expect given values to be not equal.
Definition: Macros.py:293
def ASSERT_GE
Throw exception if first given value is less than the second.
Definition: Macros.py:180
def DEBUG_STOP()
Stops a test immediately for debugging purposes.
Definition: Macros.py:525
def EXPECT_LE
Expect first given value to be less than or equal to the second.
Definition: Macros.py:241
def EXPECT_FLOAT_LT
Expect first given value to be less than the second.
Definition: Macros.py:367
def ASSERT_FLOAT_GE
Throw exception if first given value is not greater than or equal to the second.
Definition: Macros.py:329
def ASSERT_FLOAT_LE
Throw exception if first given value is not less than or equal to the second.
Definition: Macros.py:379
def ASSERT_TRUE
Throw exception if given expression does not evaluate to true.
Definition: Macros.py:60
def EXPECT_PATH_EXISTS
Expect the given path to exist.
Definition: Macros.py:465
def WARNING(msg)
Create a warning message.
Definition: Macros.py:511
def EXPECT_NE
Expect given values to be not equal.
Definition: Macros.py:144
def EXPECT_FLOAT_EQ
Expect given values to be equal.
Definition: Macros.py:267
def EXPECT_FLOAT_GE
Expect first given value to be greater than or equal to the second.
Definition: Macros.py:343
def ASSERT_FLOAT_EQ
Throw exception if given values are not equal.
Definition: Macros.py:253
def INFO(msg)
Create an info message.
Definition: Macros.py:504
def EXPECT_TRUE
Expect given expression to evaluate to true.
Definition: Macros.py:72
def ERROR(msg)
Create an error message.
Definition: Macros.py:518
def ASSERT_NOT_EMPTY
Throw exception if given container is empty.
Definition: Macros.py:433
def ASSERT_FALSE
Throw exception if given expression does not evaluate to false.
Definition: Macros.py:83
def ASSERT_NE
Throw exception if given values are equal.
Definition: Macros.py:131
def ASSERT_SIZE
Throw exception if given container does not have the given size.
Definition: Macros.py:455
def EXPECT_FLOAT_LE
Expect first given value to be less than or equal to the second.
Definition: Macros.py:393
def EXPECT_FALSE
Expect given expression to evaluate to false.
Definition: Macros.py:96