5.4. Unit tests

It is possible to test python script 'on the fly' as in the example: On-the-fly interscript for test 10 follows.
Start interscript section from tutorial.pak
   432: @head(1,'A python test')
   433: Test the test_python function.
   434: @test_python(hlevel=2,descr='A simple test',source_terminator='//')
   435: print 'A simple test'
   436: //
End interscript section from tutorial.pak
Test output at ../tests/output/test_10.html. Logfile at ../tests/output/test_10.log.

The test is also registered in a table of tests.

It is also possible to provide expected output: Interscript will verify your code by comparing the expected and actual output, and print a difference table if the test failed. Note that the difference table is only available if the module "interscript.utilities.diff" is available and operates correctly: the current implementation uses GNU diff invoked using "os.system()". Here's an example that veifies OK: On-the-fly interscript for test 11 follows.

Start interscript section from tutorial.pak
   449: @head(1,'A diff OK test')
   450: Test the test_python function.
   451: @test_python(hlevel=2,\
   452:   descr='A diff OK test',source_terminator='//', expected_terminator='//')
   453: print 'A simple diff test'
   454: print 'A simple diff test line 2'
   455: print 'A simple diff test line 3'
   456: //
   457: A simple diff test
   458: A simple diff test line 2
   459: A simple diff test line 3
   460: //
End interscript section from tutorial.pak
Test output at ../tests/output/test_11.html. Logfile at ../tests/output/test_11.log.

And here's one that should fail: On-the-fly interscript for test 12 follows.

Start interscript section from tutorial.pak
   464: @head(1,'A diff fail test')
   465: Test the test_python function.
   466: @test_python(hlevel=2,\
   467:   descr='A diff test',source_terminator='//', expected_terminator='//')
   468: print 'A simple diff test'
   469: print 'A simple diff test line 2'
   470: print 'A simple diff test line 3'
   471: //
   472: A simple diff test
   473: A simple diff test line 2 CHANGED
   474: A simple diff test line 3
   475: //
End interscript section from tutorial.pak
Test output at ../tests/output/test_12.html. Logfile at ../tests/output/test_12.log.


5.4.1. Weaver Control
5.4.2. Perl hates @