Python Forum
Validating the functionality of the application
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validating the functionality of the application
#1
I am trying to learn test script in python. I would like to write a test script to validate the functionality of an executable. The script should test the behaviour of the application, how the application handles error events and the specifications of the application are as follows,

The application takes input data from a file that is specified as an argument and is called by executable.exe numbers.txt
The numbers.txt file contains comma separated list of float number in each line
The application computes and prints the average and standard deviation values for the numbers on each line in the input file(numbers.txt)

I came up till here

from validator_collection import validators, errors

# This funcion can be used to execute the application
# Inputs: executable, the executable file of the application
#         data, the input data file for the application
# Outputs: return code, standard output, and error output from the execution
def execute_application(executable, data):
    proc = subprocess.run(
            [executable, data],
            encoding="utf-8",
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
    return proc.returncode, proc.stdout, proc.stderr

# Call application
returncode, output, error = execute_application("executable.exe", "numbers.txt")

# The output of the program is 
#Output: data.txt
#Line 1 average 11.2333 standard deviation 9.34041
#Line 2 average 7.21667 standard deviation 7.29286

# started writing the test case
val = output.split(" ")
avg1, std1 = float(val[3]), float(val[6].strip('\nLine'))
avg2, std2 = float(val[9]), float(val[12].strip('\nLine'))
try:
    ret_avg1 = validators.float(avg1)
    ret_avg2 = validators.float(avg2)
    ret_std1 = validators.float(std1)
    ret_std2 = validators.float(std2)
except ValueError:
    print('Error')

print(ret_avg1, ret_avg2, ret_std1, ret_std2)
print("Output:", output)
print("Errors:", error)
Any pointers will be helpful
Reply


Messages In This Thread
Validating the functionality of the application - by rpalakodety - Dec-30-2019, 01:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Priority Queue with update functionality PythonNewbee 4 5,096 Dec-29-2022, 12:13 PM
Last Post: Yoriz
  [split] formula for validating monetary values? kakos_k9 1 1,353 Dec-17-2022, 09:28 PM
Last Post: woooee
  How to send data from a python application to an external application aditya_rajiv 1 3,038 Jul-26-2021, 06:00 AM
Last Post: ndc85430
  Validating user input WJSwan 2 2,965 Jul-06-2020, 07:21 AM
Last Post: menator01
  Validating information from .csv file before executemany mzmingle 7 6,959 Apr-15-2019, 01:40 PM
Last Post: mzmingle
  need help with making a validating function drasil 8 5,267 Mar-28-2019, 10:38 AM
Last Post: perfringo
  I'm having trouble with an OOP version of Pickle functionality CodeWolf 2 3,250 Dec-19-2018, 05:41 PM
Last Post: CodeWolf
  Validating credit card frequency 8 5,555 Nov-05-2018, 07:36 PM
Last Post: frequency
  Validating Input (basic check for int etc) gruntfutuk 1 3,142 Aug-06-2018, 07:43 AM
Last Post: gruntfutuk
  Problem with 'Clock' functionality panoss 2 4,280 May-17-2017, 07:03 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020