@@ -26,10 +26,13 @@ using the unittest module from the Python standard library.
26
26
27
27
These directions apply to both Windows and Unix-like systems
28
28
(including Linux and Mac OS X). The directions assume that Python is
29
- already installed and your environment is configured so you can run
30
- it (if not, see http://docs.python.org/2/using/). It also assumes
31
- that PyModel is installed and its pymodel directory (containing trun.py,
32
- pmt.py etc.) is on your execution path.
29
+ already installed and your environment is configured so you can run it
30
+ (if not, see http://docs.python.org/2/using/). It also assumes that
31
+ PyModel is present on your system, the contents of its PyModel/pymodel
32
+ directory are on your Python path, the current directory is on your
33
+ Pyton path, and the contents of its PyModel/bin directory are on your
34
+ execution path. You can achieve this by executing
35
+ PyModel/bin/pymodel_paths, or the commands therein.
33
36
34
37
Quick Start
35
38
Summary
@@ -41,17 +44,18 @@ Using other unit testing frameworks
41
44
42
45
Quick Start
43
46
44
- In each subdirectory of samples, put the current directory
45
- (whatever it is) on the PYTHONPATH by executing the tpath command
46
- ("source tpath" in bash, just "tpath" in Windows). Then, type:
47
+ In each subdirectory of samples, type:
47
48
48
49
clogdiff trun test
49
50
50
51
if there are more test*.py files besides test.py, you can run them too:
51
52
52
53
clogdiff trun test_scenarios
53
54
54
- etc. If messages indicate differences were found, there may be a problem.
55
+ etc. If messages indicate differences were found, there may be a
56
+ problem. Or maybe not (see below). If messages indicate there is no
57
+ .ref file, that means the test scripts are not deterministic and this
58
+ test is not meaningful.
55
59
56
60
Notice that we only show the command you type, we do not show the
57
61
command prompt, for example usually ...> for the Windows cmd prompt
@@ -99,12 +103,11 @@ more easily coded with particular system-dependent commands (for
99
103
example: setting the execution path, checking differences between
100
104
files).
101
105
102
- These Python programs are typically used as commands: pma.py pmg.py pmt.py
103
- pmv.py trun.py and wsgirunner.py. When used as commands, the .py
104
- suffix can be omitted. For example you can type pmt -n 10 PowerSwitch
105
- instead of pmt.py ... or trun test_graphics instead of trun.py ...
106
- Both forms work (in Windows as well as Unix-like systems), and both appear in
107
- test scripts.
106
+ Invoke the four PyModel programs on the command line or in scripts by
107
+ name, without using the .py extension (pmt not pmt.py). You can also
108
+ include the .py extension (pmt.py not just pmt); some older scripts you
109
+ may still have used this form. BUT to use this form, you must put
110
+ PyModel/pymodel on your execution path (not just your Python path).
108
111
109
112
110
113
Test scripts
@@ -122,18 +125,12 @@ Here are the contents of the script in samples/WebApplication/Model/test.py:
122
125
123
126
cases = [
124
127
('Test: -a option includes only Initialize Action',
125
- 'pmt.py -n 10 -a Initialize WebModel'),
128
+ 'pmt -n 10 -a Initialize WebModel'),
126
129
127
130
('Test: -e option excludes all Login, Logout actions',
128
- 'pmt.py -n 10 -e Login_Start -e Login_Finish -e Logout WebModel'),
131
+ 'pmt -n 10 -e Login_Start -e Login_Finish -e Logout WebModel'),
129
132
]
130
133
131
- The PyModel commands in test scripts often include the .py suffix, as
132
- in pmt.py ... here. The suffix is not required, recent test scripts
133
- often use pmt ... etc. (On Unix-like systems, you must execute
134
- the symlinks command in the pymodel directory *once* after you install
135
- PyModel to enabled this).
136
-
137
134
The trun module takes one argument, the module name of the script (NOT
138
135
the file name, there is no path prefix or .py suffix). The trun
139
136
module imports the script, then iterates over the cases list, printing
@@ -144,14 +141,13 @@ contains modules to test. This command executes it:
144
141
145
142
trun test
146
143
147
- For this command to work, the pymodel directory must be on the
148
- execution PATH. The current directory must be on the PYTHONPATH.
149
- This is necessary to enable PyModel tools (such as pmt) in the pymodel
150
- directory to import modules in the current directory. The tpath
151
- command in the pymodel directory assigns the current directory to the
152
- PYTHONPATH (use 'source tpath' in bash). It is NOT necessary to
153
- repeat the tpath command after a change directory command (cd)
154
- (checked on Mac OS X - this may differ under Windows).
144
+ For this command to work, the pymodel directory must be on the Python
145
+ path, and the current directory must be on the Python path. This is
146
+ necessary to enable PyModel tools (such as pmt) in the pymodel
147
+ directory to import modules in the current directory. The
148
+ PyModel/bin/pymodel_paths command assigns these paths. It is NOT
149
+ necessary to repeat the tpath command after a change directory command
150
+ (cd) (checked on Mac OS X - this may differ under Windows).
155
151
156
152
Checking test script output
157
153
@@ -230,12 +226,12 @@ in Windows like Unix >& to redirect error output also.
230
226
231
227
Output files
232
228
233
- The PyModel pmt.py program only writes to the terminal (to stdout and
234
- stderr), but other PyModel programs write output files: pma.py writes
235
- another module (.py file) that contains the generated FSM, pmg.py
229
+ The PyModel pmt command only writes to the terminal (to stdout and
230
+ stderr), but other PyModel commands write output files: pma writes
231
+ another module (.py file) that contains the generated FSM, pmg
236
232
writes a .dot file with commands for the Graphviz dot program, and the
237
233
various dot commands (dotsvg etc.) write graphics files: .svg, .pdf,
238
- .ps etc. The pmv.py program invokes all of these programs causes all
234
+ .ps etc. The pmv program invokes all of these programs causes all
239
235
of these files to be written.
240
236
241
237
The PyModel programs write all of these output files in the current
@@ -245,7 +241,7 @@ overwitten). In the PyModel distribution, we provide copies of some
245
241
of the output files we made (on our development system) so you can
246
242
compare them to yours (that you generate when you repeat the tests on
247
243
your system). In some samples directories, there may be an fsmpy
248
- directory which contains FSM modules written by pma.py , and there may
244
+ directory which contains FSM modules written by pma, and there may
249
245
be an svg or pdf directory which contains .svg files written by pma +
250
246
pmg + dot (or pmv). You may wish to copy output files that you
251
247
generate into these directories, so you can compare them to output
@@ -272,8 +268,8 @@ The popular unit test frameworks are not so well-suited for this kind
272
268
of test. However, you can use one of the popular frameworks if you
273
269
prefer, as an alterative to our trun command and our test scripts.
274
270
There is an example in the samples/populations directory. The module
275
- test_populations.py there works with unittest to run the same tests
276
- as in tests.py. That is, instead of
271
+ test_populations there works with unittest to run the same tests
272
+ as in tests. That is, instead of
277
273
278
274
trun tests # test with our homemade framework
279
275
0 commit comments