Open iachen opened 7 months ago
The testing code needs to be put in a test function:
def test_sleep_card():
if d(resourceId="com.plumewifi.plume.dogfood:id/daily_sleep_summary_message_title").exists(timeout=3):
print("-------------------- Sleep card found ---------------------------------")
d.screenshot("./pic/Sleep-L1.png")
allure.attach.file("./pic/L1.png", attachment_type=allure.attachment_type.PNG)
The function then gets executed by pytest, and Allure creates the test result from it. When you generate the report, the attachment can be found under that test result.
@delatrie ,
The testing code needs to be put in a test function:
Thanks for the reply. Do you mean it cannot work "allure.attach.file" is outside the test function?
If so, is there any way to do the same thing? Since I'd like to take a screeshot before I start the test.
Thanks.
@delatrie ,
The testing code needs to be put in a test function:
Thanks for the reply. Do you mean it cannot work "allure.attach.file" is outside the test function?
If so, is there any way to do the same thing? Since I'd like to take a screeshot before I start the test.
Thanks.
`
import signal import allure
def func_set_timeout(timeout): """implementing by yourself""" def decorator(func): def wrapper(*args, *kwargs): signal.alarm(timeout) try: result = func(args, **kwargs) except Exception as e: raise e finally: signal.alarm(0) return result return wrapper return decorator
@func_set_timeout(120) def send_command(cmd): allure.attach(...) pass`
Hello, I'm facing the same issue here, were you able to resolve it? @iachen
I'm submitting a ...
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
Hi I am beginner for the script programming and I got problem as mentioned in following.
I wrote a test script and would like to attach screenshot to the generated Allure report. This this the part of the code which include the allure.attach part
And it will get the error with exexuting the command
pytest -vv --show-capture=all test-xxxx.py --alluredir=./result/1
The line
d.screenshot("./pic/L1.png")
which is with uiautomator2 command can work fine(screenshot is capured). And if I comment/remove the lineallure.attach.file("./pic/L1.png", attachment_type=allure.attachment_type.PNG)
, the script can run without error.Also, if I run the command without generating the allure report(
pytest -vv --show-capture=all test-xxxx.py
), the script can run and complete(so the error is caused with that line of "allure.attach.file").I surveyed and checked with https://github.com/allure-framework/allure-python/issues/431 and https://github.com/allure-framework/allure2/issues/570, looks like there is no further discussion.
What is the expected behavior?
The attached work to Allure should work.
Please tell us about your environment:
Other information
Please let me know if I need to provide more information.