Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest-robotframework 4.1.1 CRASH with robot framework 6.1.1 #249

Closed
ptmq opened this issue Mar 24, 2024 · 4 comments
Closed

pytest-robotframework 4.1.1 CRASH with robot framework 6.1.1 #249

ptmq opened this issue Mar 24, 2024 · 4 comments

Comments

@ptmq
Copy link

ptmq commented Mar 24, 2024

something went wrong with the pytest-robotframework plugin. please raise an issue at https://github.com/detachhead/pytest-robotframework with the following information:

failed to filter out pytest-robotframework machinery for exception: UnboundLocalError("local variable 'element' referenced before assignment")

full traceback:

  File "C:\Users\ta\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\ta\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Agent3\_work\61\s\.venv\Scripts\robot.exe\__main__.py", line 7, in <module>
    sys.exit(run_cli())
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\run.py", line 508, in run_cli
    return RobotFramework().execute_cli(arguments, exit=exit)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\utils\application.py", line 44, in execute_cli
    rc = self._execute(arguments, options)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\utils\application.py", line 81, in _execute
    rc = self.main(arguments, **options)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\run.py", line 458, in main
    result = suite.run(settings)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\model.py", line 606, in run
    self.visit(runner)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\testsuite.py", line 426, in visit
    visitor.visit_suite(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\visitor.py", line 131, in visit_suite
    suite.suites.visit(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\itemlist.py", line 102, in visit
    item.visit(visitor)    # type: ignore
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\testsuite.py", line 426, in visit
    visitor.visit_suite(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\visitor.py", line 131, in visit_suite
    suite.suites.visit(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\itemlist.py", line 102, in visit
    item.visit(visitor)    # type: ignore
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\testsuite.py", line 426, in visit
    visitor.visit_suite(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\visitor.py", line 132, in visit_suite
    suite.tests.visit(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\itemlist.py", line 102, in visit
    item.visit(visitor)    # type: ignore
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\model\testcase.py", line 186, in visit
    visitor.visit_test(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\suiterunner.py", line 167, in visit_test
    BodyRunner(self._context, templated=bool(test.template)).run(test.body)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 51, in run
    step.run(self._context, self._run, self._templated)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\model.py", line 112, in run
    return KeywordRunner(context, run).run(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 76, in run
    return runner.run(step, context, self._run)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 68, in run
    return_value = self._run(context, kw.args, result)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 97, in _run
    exception, return_ = self._execute(context)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 171, in _execute
    BodyRunner(context).run(handler.body)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 51, in run
    step.run(self._context, self._run, self._templated)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\model.py", line 112, in run
    return KeywordRunner(context, run).run(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 76, in run
    return runner.run(step, context, self._run)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 68, in run
    return_value = self._run(context, kw.args, result)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 97, in _run
    exception, return_ = self._execute(context)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 171, in _execute
    BodyRunner(context).run(handler.body)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 51, in run
    step.run(self._context, self._run, self._templated)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\model.py", line 112, in run
    return KeywordRunner(context, run).run(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 76, in run
    return runner.run(step, context, self._run)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 68, in run
    return_value = self._run(context, kw.args, result)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 97, in _run
    exception, return_ = self._execute(context)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 171, in _execute
    BodyRunner(context).run(handler.body)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 51, in run
    step.run(self._context, self._run, self._templated)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\model.py", line 112, in run
    return KeywordRunner(context, run).run(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 76, in run
    return runner.run(step, context, self._run)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 68, in run
    return_value = self._run(context, kw.args, result)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 97, in _run
    exception, return_ = self._execute(context)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 171, in _execute
    BodyRunner(context).run(handler.body)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 51, in run
    step.run(self._context, self._run, self._templated)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\model.py", line 112, in run
    return KeywordRunner(context, run).run(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 76, in run
    return runner.run(step, context, self._run)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 68, in run
    return_value = self._run(context, kw.args, result)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 97, in _run
    exception, return_ = self._execute(context)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\userkeywordrunner.py", line 171, in _execute
    BodyRunner(context).run(handler.body)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 51, in run
    step.run(self._context, self._run, self._templated)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\model.py", line 142, in run
    return ForRunner(context, self.flavor, run, templated).run(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 113, in run
    if self._run_loop(data, result, values_for_rounds):
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 126, in _run_loop
    self._run_one_round(data, result, values)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 227, in _run_one_round
    runner.run(data.body)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 51, in run
    step.run(self._context, self._run, self._templated)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\model.py", line 112, in run
    return KeywordRunner(context, run).run(self)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\bodyrunner.py", line 76, in run
    return runner.run(step, context, self._run)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\librarykeywordrunner.py", line 55, in run
    return_value = self._run(context, kw.args)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\librarykeywordrunner.py", line 80, in _run
    return self._run_with_output_captured_and_signal_monitor(runner, context)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\librarykeywordrunner.py", line 102, in _run_with_output_captured_and_signal_monitor
    return self._run_with_signal_monitoring(runner, context)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\librarykeywordrunner.py", line 107, in _run_with_signal_monitoring
    runner_result = runner()
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\librarykeywordrunner.py", line 95, in <lambda>
    return lambda: handler(*positional, **named)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\pytest_robotframework\__init__.py", line 310, in inner
    return self.inner(fn, context_manager, *args, **kwargs)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\pytest_robotframework\__init__.py", line 225, in inner
    with status_reporter:
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\robot\running\statusreporter.py", line 55, in __exit__
    failure = self._get_failure(exc_type, exc_val, exc_tb, context)
  File "C:\Agent3\_work\61\s\.venv\lib\site-packages\pytest_robotframework\__init__.py", line 148, in _get_failure
    + "".join(format_stack())
@DetachHead
Copy link
Owner

how are you running your test? are you using pytest or robot? by the looks of that traceback you're running robot directly.

if you run your test with pytest instead it should work:

pytest path/to/test.robot

there's an issue to document this behavior: #226

@ptmq
Copy link
Author

ptmq commented Mar 24, 2024

Hi, tests are executed with robot but python keywords are decorated with @keywod imported with "from pytest_robotframework import keyword". If this is not Ok, it should be mentioned

@DetachHead
Copy link
Owner

this isn a pytest plugin that allows for executing robot tests with pytest. if you want to use robot to execute them, then there's no reason to use pytest-robotframework

@DetachHead
Copy link
Owner

closing in favor of #226, feel free to raise another issue if you have any other questions

@DetachHead DetachHead closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants