Skip to content

Make setup and teardown settable in Keywords object #2302

Closed

Description

@jaloren

Using a prerun modifier, someone may want to turn off test setup or teardown like so.

class TestTeardown(SuiteVisitor):
    def visit_test(self, test):
        test.keywords.teardown = None
        test.keywords.setup = None

However, this fails because the setup and teardown properties are read-only. It would good if these properties could be settable as well

Activity

  1. added this to the 3.0.1 milestone on Jan 19, 2016
  2. self-assigned this
    on Jun 3, 2016
  3. changed the title [-]Make setup and teardown attributes settable in visitor object[/-] [+]Make setup and teardown settable in `Keywords` object accessible for pre-run modifiers[/+] on Jun 3, 2016
  4. changed the title [-]Make setup and teardown settable in `Keywords` object accessible for pre-run modifiers[/-] [+]Make setup and teardown settable in `Keywords` object[/+] on Jun 3, 2016
  5. pekkaklarck commented on Jun 3, 2016

    @pekkaklarck
    Member

    It's already possible to alter keywords, including setups and teardowns, but having setup/teardown directly settable is useful. I consider this pretty low priority anyway because it adds no new functionality.

  6. ombre42 commented on Jun 30, 2016

    @ombre42

    It is nice to assign a keyword to these properties, but I have a question. The unit tests are creating Keyword instances using from robot.model.keyword.Keyword. But this class is not part of the public API. Is there an example that uses only the public API or is the Keyword class now considered public?

  7. pekkaklarck commented on Jul 5, 2016

    @pekkaklarck
    Member

    Good point @ombre42. The initial use case was removing setup/teardown by setting them to None and at least I didn't think how setting to new keyword would actually work in practice.

    Unit tests use model.Keyword, but in real life you probably should use either running.Keyword or result.Keyword. I don't think exposing them via the robot.api would be a good idea because we should then also expose other related classes (e.g. TestCase) and most of these classes have same names.

    These classes themselves have already been part of the public API indirectly via the exposed ExecutionResult and TestSuiteBuilder entry points that produce them. Now the question is mainly what is the best way to import them. I would say robot.running/result.Keyword/TestCase/TestSuite are all fine. They are all already exposed like that (at least in 3.0) and should just clarify this usage in the API docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions