3 # Pulls the tests out of a python test file.
4 # Usage: make_tests test_xxx.py
6 die "Must specify a file name" if $ARGV[0] eq '';
8 if (-f
'ExtractTests.pm') {
9 eval "use ExtractTests";
13 $ARGV[0] =~ /test_(.*)\.py/;
19 next if 1 .. /generateTests/;
20 next if /^\#/ && ! $in_string;
22 if (/^\"\"\"(?: \% (.*?)\s*|\]?,\s*(?:\#.*)?)$/) {
23 my $vars = $VARS{"$counter$suffix"} || $1;
25 $vars =~ s/\b(\w+)\b/defined $DEFS{$1} ? "q($DEFS{$1})" : $1/ge;
26 my @args = eval($vars);
27 # string =~ s/\\\n//g;
28 printf FILE
$string,@args;
34 s/\\n\\$//;# if $suffix eq ".rst";
35 s/\\([\\\'\"])/$1/g unless $string_type =~ /r/;
36 s/\"\"\"\s*\+\s*\"\"\"//g;
39 elsif (/^\[?\(?([ru])?\"\"\"(.*)?$/) {
42 $suffix = $suffix eq ".dom" ?
".rst" : ".dom";
43 $counter++ if $suffix eq ".rst";
44 $file = "$outfile_base$counter$suffix";
45 open(FILE
, ">$file") or die "Cannot write to $file";