Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

(3)How to write a test for Script file

Step 1: Select a script to test: gen_coords.py

Step 2. Identify input file paths for testing

Step 3: Collect known sample inputs and their outputs and put them in the sample folders. Write a test script in the follwing structure as shown below.

 

Image Added

Step 4. Run pytest

The test script starts with imports followed by declarations. A test script usually contains setup and teardown functions to initialize and destroy any setup data that is required for the test to run. In the above script , a symbolic link is created in the setup function. Testing framework recognises the funtions that start with the "test_" name as test funtions. In the above script test test_gencords() function is the test function which runs the script to be tested externally. The difference in the results are compared. The teardown function is executed at the end. In the above example, a symbolic link created in the setup is destroyed in the teardown function since the testing has been completed.

Pytest reports the result in the following format.

 

Image AddedImage Removed

 

(4) How to write a test for Library file

...