allure-python
                                
                                 allure-python copied to clipboard
                                
                                    allure-python copied to clipboard
                            
                            
                            
                        Getting fixture not found error in allure report
Trying to run following test using pytest but getting below error. fixture 'result_type' not found.
@allure.step("Generating Test Results")
def testResultPngToPdf(result_type):
'''Function call to make pdf for all screen shots taken during execution'''
logging.info(f"Total Screenshots captured : {len(screenshots_list)}")
logging.info(f"Result type value  : {result_type}")
screenshots_list[-1] = pass_fail_watermark(result_type, screenshots_list[-1])
pdf_filename = ("TestResults/"+scenario_to_run+"_" +current_time+"_"+result_type+".pdf")
screenshots_list[0].save(pdf_filename, "PDF", resolution=100.0,
                        save_all=True, append_images=screenshots_list[1:])
screenshots_list.clear()
Please find below error:
@allure.step("Generating Test Results")
def testResultPngToPdf(result_type):
E       fixture 'result_type' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.
Please try this one
import pytest
import allure
@pytest.fixture
def result_type():
    return 'RESULT_TYPE'
@allure.title("Generating Test Results")
def testResultPngToPdf(result_type):
    '''Function call to make pdf for all screen shots taken during execution'''
    logging.info(f"Total Screenshots captured : {len(screenshots_list)}")
    logging.info(f"Result type value  : {result_type}")
    screenshots_list[-1] = pass_fail_watermark(result_type, screenshots_list[-1])
    pdf_filename = ("TestResults/"+scenario_to_run+"_" +current_time+"_"+result_type+".pdf")
    screenshots_list[0].save(pdf_filename, "PDF", resolution=100.0,
                        save_all=True, append_images=screenshots_list[1:])
    screenshots_list.clear()
Hi , Thanks for the solution.Post changing the code, it is working fine .But found one more error " IndexError: list index out of range".
@allure.title("Generating Test Results")
##pytest.fixture()
def testResultPngToPdf(result_type):
    '''Function call to make pdf for all screen shots taken during execution'''
    logging.info(f"Total Screenshots captured : {len(screenshots_list)}")
    logging.info(f"Result type value  : {result_type}")
screenshots_list[-1] = pass_fail_watermark(result_type, screenshots_list[-1])
E       IndexError: list index out of range
pytestdemo.py:538: IndexError`
Please help me resolve above issue.
if -1 index does not exist then list is empty. The problem is somewhere in your code.
your log logging.info(f"Total Screenshots captured : {len(screenshots_list)}") must print zero in console.
Anyway, that is out of the scope of the allure issue tracker.
Hi, I have defined screenshots_list as global list variable in function called takeScreenshot() and try to access same list variable in testResultPngToPdf(). and when i print the length of screenshots_list it is not empty . In allure step of testResultPngToPdf() ,same is not able to access .can you please help me to identify the exact root cause.
Code snippet for takeScreenshot()
global screenshots_list
screenshots_list = [] # Storing list of all screenshot captured  
@allure.step("Capture Screenshots")
def takeScreenshot(ind):
    '''function used to take screenshots for each event'''  
    logging.info(f"Screenshots captured!")
    filename = "temp/"+scenario_to_run+"_"+str(ind)+".png"
    driver.get_screenshot_as_file(filename)
    image = Image.open(filename)
    image = image.convert("RGB")
    screenshots_list.append(image)
   logging.info(f"inside take screenshot  sceenshotlist::::{len(screenshots_list)}")
Code snippet for testResultPngToPdf()
@allure.title("Generating Test Results")
def testResultPngToPdf(result_type):
    '''Function call to make pdf for all screen shots taken during execution'''
    logging.info(f"Total Screenshots captured : {len(screenshots_list)}")
    logging.info(f"Result type value  : {result_type}")
    screenshots_list[-1] = pass_fail_watermark(result_type, screenshots_list[-1])
    pdf_filename = ("TestResults/"+scenario_to_run+"_" +current_time+"_"+result_type+".pdf")
    screenshots_list[0].save(pdf_filename, "PDF", resolution=100.0,
                        save_all=True, append_images=screenshots_list[1:])
    screenshots_list.clear()
Hi, I have defined screenshots_list as global list variable in function called takeScreenshot() and try to access same list variable in testResultPngToPdf(). and when i print the length of screenshots_list it is not empty . In allure step of testResultPngToPdf() ,same is not able to access .can you please help me to identify the exact root cause.
That's looks like Stack Overflow kind of question and it is not Allure related
Hi, @kajal0502 ! This tracker is for allure python bugs & feature requests. Your issue doesn't seem to fall into this category to me. You probably should ask a question on https://stackoverflow.com/ as chances are much higher that someone will eventually help you with your code.
I'm closing the issue now. Feel free to reopen it if you feel that something is wrong with allure code.