Rebot issue: Different merging behavior of depending on how called

96 views
Skip to first unread message

dmitriych

unread,
Apr 30, 2021, 5:12:44 PM4/30/21
to robotframework-users
Have a test runner that uses subprocess.check_call to launch rebot. After failed tests rerun, if I call rebot as a shell command "rebot" + args, the merge is executed such that the passed and failed tests are together in the log.html. If I launch rebot as a python module, using the "python -m robot.rebot" + args, the resulting log.html only includes failed files. 
These are sample tests and failures are intentional.

DETAILS:
This command:
    merge_command = [ 'rebot',  '--output', 'newoutput.xml','--merge', 'output.xml', 'rerun.xml' ]
results in log.html with both passed and failed-after-rerun tests

However this command:
    merge_command = ['python', '-m', 'robot.rebot', '--output', 'newoutput.xml',  '--merge', 'output.xml', 'rerun.xml' ]
results in a log.html with failed-only tests reported.
CombinedRobotReport.jpg
FailedOnlyRobotReport.jpg

Dmitriy Chernoshey

unread,
May 3, 2021, 12:45:48 PM5/3/21
to robotframework-users
I figured it out. Apparently, the subprocess module does not work/recognize virtual environments, so when I do "python -m modulename" in it will launch the system-wide interpreter instance, and not the one in the Robot venv. This causes the merge failure and the results observed. When launching via batch file, everything works properly and hence different behavior. 
For those of you encountering this issue, the solution is to use sys.executable instead of 'python' when working with subprocess calls. So the above command would look like this:
[sys.executable, '-m', 'robot.rebot', '--output', 'newoutput.xml',  '--merge', 'output.xml', 'rerun.xml' ]

If you are using Pabot, remember that pabot is a package that also contains pabot.py module, so the pabot command would look like this:
[sys.executable, '-m', 'pabot.pabot', '--output', 'newoutput.xml',  '--merge', 'output.xml', 'rerun.xml' ]

--
You received this message because you are subscribed to a topic in the Google Groups "robotframework-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robotframework-users/eygxjRK3whI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/956b79d8-a23a-4820-8e31-937da9b8d7cdn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages