pyuseocl.assertion

Add support for “assertions” in USE OCL. Assertions can be added in soil files in the form of comments like the following:

-- @assert MyClass::MyInvariant1 OK
-- @assert MyClass::MyInvariant2 Failed
-- @assert MyClass::MyInvariant6 OK

... the rest of the soil file ...

The “tester” engine will extract any assertion in the soil file and check if the expected results conform to what USE OCL interpreter return. This module is to be used with the ‘tester’ module.

Classes

InvariantAssertion(useModel, stateFile, ...) An InvariantAssertion bound to an invariant of a given model or an invalid InvariantAssertion if the invariant cannot be found.
InvariantAssertionEvaluation(...) The evaluation of an InvariantAssertion against a model if thr assertion is correct.

InvariantAssertion

class pyuseocl.assertion.InvariantAssertion(useModel, stateFile, className, invariantName, expectedResult)[source]

An InvariantAssertion bound to an invariant of a given model or an invalid InvariantAssertion if the invariant cannot be found. Just indicates what is the expected result for this invariant.

isCorrect = None

bool

expectedResult = None

bool

InvariantAssertionEvaluation

class pyuseocl.assertion.InvariantAssertionEvaluation(invariantAssertion, actualResult)[source]

The evaluation of an InvariantAssertion against a model if thr assertion is correct. If the assertion is incorrect then the evaluation is a failure. The status can therefore have three values:

  • ‘OK’: the assertion is correct and it evaluate to the expected result,
  • ‘KO’: the assertion is correct and it evaluate to a unepected result,
  • ‘Failure’: the assertion is incorrect