212 IX: IX Script Testing of Software (212.html)

Keywords

ICH180RR Script Testing Software Test requires Func Macally MKEYE keyboard Insert/Overstrike venv

/KeywordsEnd

(To enlarge .....Click it)
thumb: IXimage.jpg
IX or (IX by DC) or "|><"


This article is a part of the IX family of software.

Introduction

The Author has developed a system for testing simple software routines eg simple functions. It is called the "IX Script Test".

The type of software module that can make the best use of "IX Script Test" is a function that reads in one phrase or record, processes it and produces a result that is a single phrase or record.

When using "IX Script Test", 3 files are usually needed:
1. The function to be tested, named "Func(a)" defined in Func.py
2. The "Script_Test_File_Func.txt"
3. The "Script_Test_Func.py" program

They are described in turn below.

The function to be tested

The function to be tested usually has already been written but needs to be tested. For example, a Python function named "Func(a)" is ready for testing. The function to be tested should accept one parameter as input and should return one string as output. The actual function can be very simple or very complicated.

A very simple example of Func(a) might be:

def Func(parm1):
    result="J"+parm1
    return result
This function simply prefixes the letter "J" to parm1. For every parm1 string, a valid result is easy to predict or verify.

The "Script_Test_File_Func.txt"

This script is a normal text file that will be stored in the same folder as the function to be tested. An example is shown below:
# "Script_Test_File_Func.txt"
# by D@CC
# on 2023LDec01
table}>>>Jtable}
a}>>>Ja}
four corners}>>>Jfourcorners}
}>>>J}
" "}>>>"J "}
#/end
All comment lines are preceded by a "#" and are not used as test data. This script only tests five input phrases. As can be seen, the input phrase is to the left of the "}>>>". The expected (valid) result is shown between the "}>>>" and the final "}".

3. The "Script_Test_Func.py" program

The test program is a very simple program, that requires only a few code changes.
The test program will be named "Script_Test_Func.py". For this example, it can be seen in Source 01.
The only necessary code changes are:
	Line   OLD CODE                         NEW CODE
	11     def Script_Test_???(parm1)       def Script_Test_Func(parm1)
	24     requires("???(s)")               requires("Func(s)")
	30     TestFileName="???"		TestFileName="Script_Test_File_Func.txt"
	60     result=????(parm1)               result=Func(parm1)
	
As can be seen, the test program is given a name, the function name must be specified and the Script file must be identified. No more, no less.

When this program is run, it will produce the following output:
	fut requires("Func(s)")
	31 date: 2023LDec01
	32 ScriptFileName:Script_Test_File_Func.txt
	rec T/F {inStr}      >>> {outStr}
	4   T   {table}      >>> {Jtable}
	5   T   {a}       >>> {Ja}
	6   F   {four corners} >>> {Jfourcorners}
	6   F                  >>> {Jfour corners}
	7   T   {}       >>>  {J}
	8   F   {" "}    >>>  {"J "}
	8   F            >>>  {J" "}
	NOT All Passed.
	
The final line lets us know that NOT all script lines passed the test. Script line 6 did not produce the expected result. For line 6, the result "expected" by the script is shown on the first line. The actual result appears on the line directly underneath. It is "lined up" to facilitate a visual inspection with the expected result. When an unexpected result occurs, either the function failed, or the script "expected" the wrong result. It is up to the programmer to determine the error. In this case, the function was way too simple to have failed. So, of course, the script was wrong. The script should have expected a space between "four" and "corners".

But script line 8 also failed. It was expected that the "J" appear within the pair of double quotes. This is an example of a program error in the Function being tested. To correct this error, the Function must be changed.

That is all that this Script Test does. However, the script can be as long as the programmer wishes. Furthermore, the Function can also be as complicated as the programmer needs it to be. More test data will test more different input data combinations. Every time a change is made to the Function, the same script (or a longer script) can be used to verify that the revised function still works as before. If the function being tested fails when live data is used, the new live data can be easily added to the script.

A longer script can verify new combinations to test the revisions.

Any ERRORS or WARNINGS produced by the test Function will also appear.

There are many advantages to using a test script over "live programmer testing". The main advantage is that the test script can be prepared in advance by a more knowledgable programmer (or the manager or a real user). Having a test script is extremely valuable whenever changes are made to a Function.

Source 02 is an actual Test Script (and its result) that was used to test the function "preParse()" that the author uses in the IXp macro preprocessor. As can be seen, the special concerns are/were whether different combinations of pairs of double quotes and pairs of single quotes would be handled correctly in the CLI that is input to the IXp program.

In Source 02, there are three files concatenated together. They are the Script Test file, the Script Test program and the Script Test results. Note that all the lines of the script passed, but one warning was issued. The definition of the actual preParse() function was not included, because it adds nothing to see all the statements in this complex function definition.

The goal of the preParse() function is to examine a command line input (CLI). If any space is found anywhere within double quotes, it is to be converted into "&20". This conversion keeps a space within double quotes within a text string, but leaves unchanged any spaces that separate parameters. Many common constructs of a IXp CLI appear in the Test Script.

Other Thoughts

Macally keyboard and key=combos

I have a wired keyboard made by Macally, Model MKEYE (shown below left). There is no obvious key to toggle between Insert and Overstrike mode. Perhaps this can also be toggled by an editor or an OS. Most keyboards have a key to toggle this. The simple on-line Macally manual doesn't mention Insert/Overstrike. I requested Macally technical support by email on 2023LDec02. On 2023LDec06, they replied that there is no such key on their keyboard. On a keyboard designed for Windows, the Insert/Overstrike key is 0 on the numeric KeyPad, if the keypad is in non-numeric mode. Linux provides this same key-binding. See Source 07 for instructions how to toggle Scroll-Lock on a Mac keyboard.

(To enlarge .....Click it)
thumb: IMG_0052.jpg
Macally MKEYE keyboard


(To enlarge .....Click it)
thumb: RPi_default_keyboard.jpg
RPi_default_keyboard


(To enlarge .....Click it)
thumb: ScrollLockedKeys.jpg
Scroll Locked Numeric Keys


ScrollLockedKeys.jpg
See Source 05 for a more complete description of the Fn keys in non-Fn mode on the Macally keyboard.
The right-most LED in the top right-hand corner is the Scroll-Lock LED.  In Scroll-Lock mode, the keys
on the keypad are given special meanings by Linux.  It is Linux that uses a key-binding to give the
keypad-0 the Insert/Overstrike meaning in non-numeric keylock mode.

On my Raspberry Pi 4B, I select this keyboard to be the default "Generic 105-key PC".

In my environment, some of my key-combinations are:


Key-Combo	Result (in MousePad Edit on a Raspberry Pi 4B with Raspbian OS "bookworm")
----------	----------------------------------------------------------------
Shift+Home	will highlight the current row from current column to the left.
Ctrl+Q		will Quit (Close) the edit window.
F1		opens web browser help
F11		Full-Screen Window toggle
Ctrl+Alt+Del	Switch User / Power Off
Ctrl+P 		Print
Fn+F3		Find (In Web Browser), is a tiny visible Paste Buffer (from anywhere)
Fn+F7		Make Cursor Invisible
Fn+F9		toggles audio mute
Fn+F10		Editor File Submenu
Ctrl+>		Smilies
Ctrl-Alt-B	Bluetooth submenu
Ctrl-Alt-W	WiFi submenu
Ctrl-Alt-T	Open Terminal Window
Ctrl-Alt-M	toggle Magnify Screen
Ctrl+-		Minify (opposite of Magnify)
Ctrl+0		UnMinify
Option+Tab	Toggle between Open Windows
Alt+Tab		Toggle between Open Windows
Cmd-Alt-PrtSc	Menu Search
Cmd-Alt-F13	Menu Search
Cmd+I		toggles color negative (inversion)
Cmd+F1		opens edit help in the web browser
Cmd tap		Main Menu (char to search)
0(on keypad)	Insert/Overstrike (with numLock off)

Note: 		Option is Alt
Note:		tap is a quick tap of the key


See Source 06 for suggested RPi keyboard Shortcuts with OS "bullseye".

CM4 Suppliers and TDBank

Source 03 lists many suppliers of CM4-related devices.

Source 04 describes TDBank's first locations in Bradenton.

Python and Thonny under RPi bookworm OS need Venv

In Source 08 Roel Peters tells how to set up a venv (Virtual Environment) for Python when running Python or Thonny under the bookworm OS. I will begin to do this asap as one more step towards using the Raspberry Pi 5. I wonder if a venv is backwards compatible with operating systems earlier than bookworm.

Sources

Video Sources

Video Source V212:01: FINALLY! NVMe SSDs on the Raspberry Pi (13:30m) by Jeff Geerling c 2023 K Nov 16

Web Sources

Web Source S212:01:www requires_v01_py.txt by D@CC on 2023JOct26
Web Source S212:02:www IX Script_Test_preParse_All.txt by D@CC on 2023LDec01
Web Source S212:03:www Raspberry_CM4_Stuff.txt by D@CC on 2023LDec09
Web Source S212:04:www TDBank_Bradenton.txt by D@CC on 2023LDec09
Web Source S212:05:www Help Macally qkeys by Macally before 2023LDec10
Web Source S212:06:www Best RPi Keyboard Shortcuts. . . (and keybind) by Arjun Sha at Beeborm on 2021ISep13
Web Source S212:07:www . . . Scroll Lock on a Mac Keyboard by Kimanthi Sammy on 2023KNov17
Web Source S212:08:www . . . Thonny with a Virtual Environment on RPi by Roel Peters on 2019ISep04

/SourcesEnd


There is a way to "google" any of the part-numbers, words or phrases in all my articles. This "google-like" search limits itself ONLY to my articles. Just go to the top of "Articles by Old King Cole" and look for the "search" input box named "freefind".

Click here to return to Articles by Old King Cole

Date Created:2023 L Dec 01
Last Updated:2023 L Dec 14

All rights reserved 2024 by © ICH180RR

saved in E:\E\2022\DevE\MyPagesE\Globat\ePhotoCaption.com\a\212\212.html
backed up to ePhotoCaption.com\a\212\212_2023LDec01.html

Font: Courier New 10 (monospaced)
/212.html