43class AssertException (Exception):
45 def __init__ (self, reason):
46 self.__reason = reason
51 return repr(self.__reason)
56 return repr(self.__reason)
66@UseStackFrameFromCallerForLogging
68 if not Base_verifyTrue(expr, comment = msg, logOnSuccess = logOnSuccess):
69 raise AssertException(
"Expression does not evaluate to true.")
78@UseStackFrameFromCallerForLogging
80 return Base_verifyTrue(expr, comment = msg, logOnSuccess = logOnSuccess)
89@UseStackFrameFromCallerForLogging
91 if not Base_verifyFalse(expr, comment = msg, logOnSuccess = logOnSuccess):
92 raise AssertException(
"Expression does not evaluate to false.")
102@UseStackFrameFromCallerForLogging
104 return Base_verifyFalse(expr, comment = msg, logOnSuccess = logOnSuccess)
113@UseStackFrameFromCallerForLogging
114def ASSERT_EQ (expected, actual, msg=None, logOnSuccess=None):
115 if not Base_compareEqual(expected, actual, comment = msg, logOnSuccess = logOnSuccess):
116 raise AssertException(
"Values (%s and %s) are not equal." % (str(expected), str(actual)))
126@UseStackFrameFromCallerForLogging
127def EXPECT_EQ (expected, actual, msg=None, logOnSuccess=None):
128 return Base_compareEqual(expected, actual, comment = msg, logOnSuccess = logOnSuccess)
137@UseStackFrameFromCallerForLogging
138def ASSERT_NE (expected, actual, msg=None, logOnSuccess=None):
139 if not Base_compareNotEqual(expected, actual, comment = msg, logOnSuccess = logOnSuccess):
140 raise AssertException(
"Values (%s and %s) are equal." % (str(expected), str(actual)))
150@UseStackFrameFromCallerForLogging
151def EXPECT_NE (expected, actual, msg=None, logOnSuccess=None):
152 return Base_compareNotEqual(expected, actual, comment = msg, logOnSuccess = logOnSuccess)
162@UseStackFrameFromCallerForLogging
164 if not Base_compareLessThan(b, a, comment = msg, logOnSuccess = logOnSuccess):
165 raise AssertException(
"Value %s not greater than %s." % (str(a), str(b)))
175@UseStackFrameFromCallerForLogging
177 return Base_compareLessThan(b, a, comment = msg, logOnSuccess = logOnSuccess)
186@UseStackFrameFromCallerForLogging
188 if not Base_compareLessThanOrEqual(b, a, comment = msg, logOnSuccess = logOnSuccess):
189 raise AssertException(
"Value %s not greater than or equal to %s." % (str(a), str(b)))
199@UseStackFrameFromCallerForLogging
201 return Base_compareLessThanOrEqual(b, a, comment = msg, logOnSuccess = logOnSuccess)
210@UseStackFrameFromCallerForLogging
212 if not Base_compareLessThan(a, b, comment = msg, logOnSuccess = logOnSuccess):
213 raise AssertException(
"Value %s not less than %s." % (str(a), str(b)))
223@UseStackFrameFromCallerForLogging
225 return Base_compareLessThan(a, b, comment = msg, logOnSuccess = logOnSuccess)
234@UseStackFrameFromCallerForLogging
236 if not Base_compareLessThanOrEqual(a, b, comment = msg, logOnSuccess = logOnSuccess):
237 raise AssertException(
"Value %s not less than or equal to %s." % (str(a), str(b)))
247@UseStackFrameFromCallerForLogging
249 return Base_compareLessThanOrEqual(a, b, comment = msg, logOnSuccess = logOnSuccess)
259@UseStackFrameFromCallerForLogging
261 if not Base_compareFloatEqual(expected, actual, msg, epsilon, logOnSuccess):
262 raise AssertException(
"Values (%s and %s) not equal." % (str(expected), str(actual)))
273@UseStackFrameFromCallerForLogging
275 return Base_compareFloatEqual(expected, actual, msg, epsilon, logOnSuccess)
285@UseStackFrameFromCallerForLogging
287 if not Base_compareFloatNotEqual(expected, actual, msg, epsilon, logOnSuccess):
288 raise AssertException(
"Values (%s and %s) equal." % (str(expected), str(actual)))
299@UseStackFrameFromCallerForLogging
301 return Base_compareFloatNotEqual(expected, actual, msg, epsilon, logOnSuccess)
310@UseStackFrameFromCallerForLogging
312 if not Base_compareFloatLessThan(b, a, comment = msg, logOnSuccess = logOnSuccess):
313 raise AssertException(
"Value %s not greater than %s." % (str(a), str(b)))
323@UseStackFrameFromCallerForLogging
325 return Base_compareFloatLessThan(b, a, comment = msg, logOnSuccess = logOnSuccess)
335@UseStackFrameFromCallerForLogging
337 if not Base_compareFloatLessThanOrEqual(b, a, msg, epsilon, logOnSuccess):
338 raise AssertException(
"Value %s not greater than or equal to %s." % (str(a), str(b)))
349@UseStackFrameFromCallerForLogging
351 return Base_compareFloatLessThanOrEqual(b, a, msg, epsilon, logOnSuccess)
360@UseStackFrameFromCallerForLogging
362 if not Base_compareFloatLessThan(a, b, comment = msg, logOnSuccess = logOnSuccess):
363 raise AssertException(
"Value %s not less than %s." % (str(a), str(b)))
373@UseStackFrameFromCallerForLogging
375 return Base_compareFloatLessThan(a, b, comment = msg, logOnSuccess = logOnSuccess)
385@UseStackFrameFromCallerForLogging
387 if not Base_compareFloatLessThanOrEqual(a, b, msg, epsilon, logOnSuccess):
388 raise AssertException(
"Value %s not less than or equal to %s." % (str(a), str(b)))
399@UseStackFrameFromCallerForLogging
401 return Base_compareFloatLessThanOrEqual(a, b, msg, epsilon, logOnSuccess)
410@UseStackFrameFromCallerForLogging
412 return Base_compareEqual( 0, len( a ), comment = msg, logOnSuccess = logOnSuccess )
419@UseStackFrameFromCallerForLogging
421 if not Base_compareEqual( 0, len( a ), comment = msg, logOnSuccess = logOnSuccess ):
422 raise AssertException(
"Container %s is not empty." % (str(a)) )
430@UseStackFrameFromCallerForLogging
432 return Base_compareLessThan( 0, len( a ), comment = msg, logOnSuccess = logOnSuccess )
439@UseStackFrameFromCallerForLogging
441 if not Base_compareLessThan( 0, len( a ), comment = msg, logOnSuccess = logOnSuccess ):
442 raise AssertException(
"Container %s is empty." % (str(a)) )
451@UseStackFrameFromCallerForLogging
453 return Base_compareEqual( size, len( a ), comment = msg, logOnSuccess = logOnSuccess )
461@UseStackFrameFromCallerForLogging
463 if not Base_compareEqual( size, len( a ), comment = msg, logOnSuccess = logOnSuccess ):
464 raise AssertException(
"Container %s size is not %s." % (str(a), str(size)) )
471@UseStackFrameFromCallerForLogging
473 contextMsg =
"Path = %s" % path
474 return Base_verifyTrue(os.path.exists(path), comment = msg, msg=contextMsg, logOnSuccess = logOnSuccess)
481@UseStackFrameFromCallerForLogging
483 contextMsg =
"Path = %s" % path
484 return Base_verifyFalse(os.path.exists(path), comment = msg, msg=contextMsg, logOnSuccess = logOnSuccess)
491@UseStackFrameFromCallerForLogging
493 contextMsg =
"Path = %s" % path
494 if not Base_verifyTrue(os.path.exists(path), comment = msg, msg=contextMsg, logOnSuccess = logOnSuccess):
495 raise AssertException(
"Path does not exist: %s" % path)
502@UseStackFrameFromCallerForLogging
504 contextMsg =
"Path = %s" % path
505 if not Base_verifyFalse(os.path.exists(path), comment = msg, msg=contextMsg, logOnSuccess = logOnSuccess):
506 raise AssertException(
"Path exists: %s" % path)
510@UseStackFrameFromCallerForLogging
512 Logging_info(msg, depth=1)
517@UseStackFrameFromCallerForLogging
519 Logging_warning(msg, depth=1)
524@UseStackFrameFromCallerForLogging
526 Logging_error(msg, depth=1)
531@UseStackFrameFromCallerForLogging
533 Logging_info(
"Stopping because of DEBUG_STOP()", depth=1)
534 Logging_setStopped(
True)
535 raise CancelTestException
538from .Base
import verifyFalse
as Base_verifyFalse, verifyTrue
as Base_verifyTrue, \
539 compareEqual
as Base_compareEqual, compareNotEqual
as Base_compareNotEqual, \
540 compareLessThan
as Base_compareLessThan, compareLessThanOrEqual
as Base_compareLessThanOrEqual, \
541 compareFloatEqual
as Base_compareFloatEqual, compareFloatNotEqual
as Base_compareFloatNotEqual, \
542 compareFloatLessThanOrEqual
as Base_compareFloatLessThanOrEqual, \
543 compareFloatLessThan
as Base_compareFloatLessThan
544from .Logging
import error
as Logging_error, warning
as Logging_warning, info
as Logging_info, setStopped
as Logging_setStopped
WARNING(msg)
Create a warning message.
ASSERT_NOT_EMPTY(a, msg=None, logOnSuccess=None)
Throw exception if given container is empty.
EXPECT_EMPTY(a, msg=None, logOnSuccess=None)
Expect given container to be empty.
EXPECT_EQ(expected, actual, msg=None, logOnSuccess=None)
Expect given values to be equal.
EXPECT_FLOAT_LE(a, b, msg=None, epsilon=0.0001, logOnSuccess=None)
Expect first given value to be less than or equal to the second.
EXPECT_TRUE(expr, msg=None, logOnSuccess=None)
Expect given expression to evaluate to true.
EXPECT_LT(a, b, msg=None, logOnSuccess=None)
Expect first given value to be less than the second.
EXPECT_SIZE(a, size, msg=None, logOnSuccess=None)
Expect given container to have the given size.
ASSERT_PATH_MISSING(path, msg=None, logOnSuccess=None)
Throw exception if given path is not missing, i.e.
EXPECT_FLOAT_LT(a, b, msg=None, logOnSuccess=None)
Expect first given value to be less than the second.
EXPECT_NE(expected, actual, msg=None, logOnSuccess=None)
Expect given values to be not equal.
ERROR(msg)
Create an error message.
EXPECT_FLOAT_EQ(expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None)
Expect given values to be equal.
ASSERT_FLOAT_GT(a, b, msg=None, logOnSuccess=None)
Throw exception if first given value is not greater than the second.
ASSERT_PATH_EXISTS(path, msg=None, logOnSuccess=None)
Throw exception if given path does not exists.
ASSERT_FLOAT_LE(a, b, msg=None, epsilon=0.0001, logOnSuccess=None)
Throw exception if first given value is not less than or equal to the second.
EXPECT_FLOAT_GE(a, b, msg=None, epsilon=0.0001, logOnSuccess=None)
Expect first given value to be greater than or equal to the second.
ASSERT_NE(expected, actual, msg=None, logOnSuccess=None)
Throw exception if given values are equal.
ASSERT_GE(a, b, msg=None, logOnSuccess=None)
Throw exception if first given value is less than the second.
DEBUG_STOP()
Stops a test immediately for debugging purposes.
ASSERT_LT(a, b, msg=None, logOnSuccess=None)
Throw exception if first given value is not less than the second.
EXPECT_NOT_EMPTY(a, msg=None, logOnSuccess=None)
Expect given container to be not empty.
ASSERT_EQ(expected, actual, msg=None, logOnSuccess=None)
Throw exception if given values are not equal.
ASSERT_FALSE(expr, msg=None, logOnSuccess=None)
Throw exception if given expression does not evaluate to false.
EXPECT_LE(a, b, msg=None, logOnSuccess=None)
Expect first given value to be less than or equal to the second.
ASSERT_FLOAT_NE(expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None)
Throw exception if given values are equal.
ASSERT_LE(a, b, msg=None, logOnSuccess=None)
Throw exception if first given value is not less than or equal to the second.
ASSERT_SIZE(a, size, msg=None, logOnSuccess=None)
Throw exception if given container does not have the given size.
ASSERT_FLOAT_EQ(expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None)
Throw exception if given values are not equal.
EXPECT_FALSE(expr, msg=None, logOnSuccess=None)
Expect given expression to evaluate to false.
ASSERT_GT(a, b, msg=None, logOnSuccess=None)
Throw exception if first given value is less than or equal to the second.
ASSERT_FLOAT_LT(a, b, msg=None, logOnSuccess=None)
Throw exception if first given value is not less than the second.
INFO(msg)
Create an info message.
EXPECT_FLOAT_NE(expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None)
Expect given values to be not equal.
EXPECT_GT(a, b, msg=None, logOnSuccess=None)
Expect first given value to be greater than the second.
EXPECT_FLOAT_GT(a, b, msg=None, logOnSuccess=None)
Expect first given value to be greater than the second.
ASSERT_FLOAT_GE(a, b, msg=None, epsilon=0.0001, logOnSuccess=None)
Throw exception if first given value is not greater than or equal to the second.
EXPECT_PATH_EXISTS(path, msg=None, logOnSuccess=None)
Expect the given path to exist.
ASSERT_EMPTY(a, msg=None, logOnSuccess=None)
Throw exception if given container is not empty.
ASSERT_TRUE(expr, msg=None, logOnSuccess=None)
Throw exception if given expression does not evaluate to true.
EXPECT_PATH_MISSING(path, msg=None, logOnSuccess=None)
Expect the given path to be missing, i.e.
EXPECT_GE(a, b, msg=None, logOnSuccess=None)
Expect first given value to be greater than or equal to the second.