Robot Framework
robot.model.testcase.TestCase Class Reference

Base model for a single test case. More...

Inheritance diagram for robot.model.testcase.TestCase:
robot.model.modelobject.ModelObject metaclass robot.result.model.TestCase robot.running.model.TestCase

Public Member Functions

def __init__ (self, name='', doc='', tags=None, timeout=None, lineno=None, parent=None)
 
def __str__ (self)
 
def body (self, body)
 Test body as a :class:~robot.model.body.Body object. More...
 
def tags (self, tags)
 Test tags as a :class:~.model.tags.Tags object. More...
 
def visit (self, visitor)
 :mod:Visitor interface <robot.model.visitor> entry-point. More...
 
- Public Member Functions inherited from robot.model.modelobject.ModelObject
def __repr__ (self)
 
def config (self, **attributes)
 Configure model object with given attributes. More...
 
def copy (self, **attributes)
 Return shallow copy of this object. More...
 
def deepcopy (self, **attributes)
 Return deep copy of this object. More...
 

Public Attributes

 body
 
 doc
 
 lineno
 
 name
 
 parent
 
 tags
 
 timeout
 

Static Public Attributes

 body_class = Body
 
 fixture_class = Keyword
 
tuple repr_args = ('name',)
 
- Static Public Attributes inherited from robot.model.modelobject.ModelObject
tuple repr_args = ()
 

Properties

 has_setup = property
 Check does a suite have a setup without creating a setup object. More...
 
 has_teardown = property
 Check does a test have a teardown without creating a teardown object. More...
 
 id = property
 Test case id in format like s1-t3. More...
 
 keywords = property
 Deprecated since Robot Framework 4.0. More...
 
 longname = property
 Test name prefixed with the long name of the parent suite. More...
 
 setup = property
 Test setup as a :class:~.model.keyword.Keyword object. More...
 
 source = property
 
 teardown = property
 Test teardown as a :class:~.model.keyword.Keyword object. More...
 

Private Member Functions

def has_setup (self)
 
def has_teardown (self)
 
def id (self)
 
def keywords (self)
 
def keywords (self, keywords)
 
def longname (self)
 
def setup (self)
 
def setup (self, setup)
 
def source (self)
 
def teardown (self)
 
def teardown (self, teardown)
 

Private Attributes

 _setup
 
 _teardown
 

Static Private Attributes

list __slots__ = ['parent', 'name', 'doc', 'timeout', 'lineno', '_setup', '_teardown']
 

Detailed Description

Base model for a single test case.

Extended by :class:`robot.running.model.TestCase` and
:class:`robot.result.model.TestCase`.

Definition at line 31 of file testcase.py.

Constructor & Destructor Documentation

◆ __init__()

def robot.model.testcase.TestCase.__init__ (   self,
  name = '',
  doc = '',
  tags = None,
  timeout = None,
  lineno = None,
  parent = None 
)

Reimplemented in robot.running.model.TestCase.

Definition at line 37 of file testcase.py.

Member Function Documentation

◆ __str__()

def robot.model.testcase.TestCase.__str__ (   self)

Definition at line 188 of file testcase.py.

◆ body()

def robot.model.testcase.TestCase.body (   self,
  body 
)

Test body as a :class:~robot.model.body.Body object.

Definition at line 51 of file testcase.py.

◆ has_setup()

def robot.model.testcase.TestCase.has_setup (   self)
private

Definition at line 108 of file testcase.py.

◆ has_teardown()

def robot.model.testcase.TestCase.has_teardown (   self)
private

Definition at line 137 of file testcase.py.

◆ id()

def robot.model.testcase.TestCase.id (   self)
private

Definition at line 164 of file testcase.py.

◆ keywords() [1/2]

def robot.model.testcase.TestCase.keywords (   self)
private

Definition at line 147 of file testcase.py.

◆ keywords() [2/2]

def robot.model.testcase.TestCase.keywords (   self,
  keywords 
)
private

Definition at line 153 of file testcase.py.

◆ longname()

def robot.model.testcase.TestCase.longname (   self)
private

Definition at line 173 of file testcase.py.

◆ setup() [1/2]

def robot.model.testcase.TestCase.setup (   self)
private

Definition at line 85 of file testcase.py.

◆ setup() [2/2]

def robot.model.testcase.TestCase.setup (   self,
  setup 
)
private

Definition at line 92 of file testcase.py.

◆ source()

def robot.model.testcase.TestCase.source (   self)
private

Reimplemented in robot.running.model.TestCase.

Definition at line 181 of file testcase.py.

◆ tags()

def robot.model.testcase.TestCase.tags (   self,
  tags 
)

Test tags as a :class:~.model.tags.Tags object.

Definition at line 56 of file testcase.py.

◆ teardown() [1/2]

def robot.model.testcase.TestCase.teardown (   self)
private

Definition at line 118 of file testcase.py.

◆ teardown() [2/2]

def robot.model.testcase.TestCase.teardown (   self,
  teardown 
)
private

Definition at line 125 of file testcase.py.

◆ visit()

def robot.model.testcase.TestCase.visit (   self,
  visitor 
)

:mod:Visitor interface <robot.model.visitor> entry-point.

Definition at line 185 of file testcase.py.

Member Data Documentation

◆ __slots__

list robot.model.testcase.TestCase.__slots__ = ['parent', 'name', 'doc', 'timeout', 'lineno', '_setup', '_teardown']
staticprivate

Definition at line 35 of file testcase.py.

◆ _setup

robot.model.testcase.TestCase._setup
private

Definition at line 46 of file testcase.py.

◆ _teardown

robot.model.testcase.TestCase._teardown
private

Definition at line 47 of file testcase.py.

◆ body

robot.model.testcase.TestCase.body

Definition at line 45 of file testcase.py.

◆ body_class

robot.model.testcase.TestCase.body_class = Body
static

Definition at line 32 of file testcase.py.

◆ doc

robot.model.testcase.TestCase.doc

Definition at line 40 of file testcase.py.

◆ fixture_class

robot.model.testcase.TestCase.fixture_class = Keyword
static

Definition at line 33 of file testcase.py.

◆ lineno

robot.model.testcase.TestCase.lineno

Definition at line 43 of file testcase.py.

◆ name

robot.model.testcase.TestCase.name

Definition at line 39 of file testcase.py.

◆ parent

robot.model.testcase.TestCase.parent

Definition at line 44 of file testcase.py.

◆ repr_args

tuple robot.model.testcase.TestCase.repr_args = ('name',)
static

Definition at line 34 of file testcase.py.

◆ tags

robot.model.testcase.TestCase.tags

Definition at line 41 of file testcase.py.

◆ timeout

robot.model.testcase.TestCase.timeout

Definition at line 42 of file testcase.py.

Property Documentation

◆ has_setup

robot.model.testcase.TestCase.has_setup = property
static

Check does a suite have a setup without creating a setup object.

    A difference between using ``if test.has_setup:`` and ``if test.setup:``
    is that accessing the :attr:`setup` attribute creates a :class:`Keyword`
    object representing the setup even when the test actually does not have
    one. This typically does not matter, but with bigger suite structures
    containing a huge about of tests it can have an effect on memory usage.

    New in Robot Framework 5.0.

Definition at line 106 of file testcase.py.

◆ has_teardown

robot.model.testcase.TestCase.has_teardown = property
static

Check does a test have a teardown without creating a teardown object.

    See :attr:`has_setup` for more information.

    New in Robot Framework 5.0.

Definition at line 135 of file testcase.py.

◆ id

robot.model.testcase.TestCase.id = property
static

Test case id in format like s1-t3.

    See :attr:`TestSuite.id <robot.model.testsuite.TestSuite.id>` for
    more information.

Definition at line 162 of file testcase.py.

◆ keywords

robot.model.testcase.TestCase.keywords = property
static

Deprecated since Robot Framework 4.0.

    Use :attr:`body`, :attr:`setup` or :attr:`teardown` instead.

Definition at line 145 of file testcase.py.

◆ longname

robot.model.testcase.TestCase.longname = property
static

Test name prefixed with the long name of the parent suite.

Definition at line 171 of file testcase.py.

◆ setup

robot.model.testcase.TestCase.setup = property
static

Test setup as a :class:~.model.keyword.Keyword object.

    This attribute is a ``Keyword`` object also when a test has no setup
    but in that case its truth value is ``False``.

    Setup can be modified by setting attributes directly::

        test.setup.name = 'Example'
        test.setup.args = ('First', 'Second')

    Alternatively the :meth:`config` method can be used to set multiple
    attributes in one call::

        test.setup.config(name='Example', args=('First', 'Second'))

    The easiest way to reset the whole setup is setting it to ``None``.
    It will automatically recreate the underlying ``Keyword`` object::

        test.setup = None

    New in Robot Framework 4.0. Earlier setup was accessed like
    ``test.keywords.setup``.

Definition at line 83 of file testcase.py.

◆ source

robot.model.testcase.TestCase.source = property
static

Definition at line 179 of file testcase.py.

◆ teardown

robot.model.testcase.TestCase.teardown = property
static

Test teardown as a :class:~.model.keyword.Keyword object.

    See :attr:`setup` for more information.

Definition at line 116 of file testcase.py.


The documentation for this class was generated from the following file: