Menu

Test python code with SASUnit

Anonymous
2024-05-06
2024-05-06
  • Anonymous

    Anonymous - 2024-05-06

    Do you think it would be possible to test python code with SASUnit (e.g using proc python), or would I need a separate testing tool for that?

    Br

    Henrik

     
  • Klaus Landwich

    Klaus Landwich - 2024-05-06

    Hi Henrik,

    yes, it is possible to "test" python code with SASUnit.

    You can start the call to python as your test call in SASUnit.
    I'm not sure what portion of the python log / output will be visible in the SAS log file.
    That surely depends on the way you call the python program.
    You can then check the results (e.g. report or data set) with SASUnit.

    %initScenario(i_desc=Tests for python program xyz);
    
    %initTestcase(i_object=call_python_program_xyz.sas, i_desc=Call with Parameters abc)
    <...call python program xyz...>
    %endTestCall()
    
    /* Do all the testing that's appropriate */
    %assertLog (i_errors=0, i_warnings=0)
    <...more Tests...>
    %endTestCase()
    
    %endScenario();
    

    As far as i know PROC PYTHON is only available in SAS Viya. Please keep in mind that the batch processing of SASUnit is not yet compatible with SAS Viya.
    You can use filename pipe to run your python programs is SAS9.4

    Regards
    Klaus

     

Anonymous
Anonymous

Add attachments
Cancel