1 '''small run test cases'''
4 from __future__
import with_statement
11 from nose
.tools
import *
15 # program and initial args required to run from test directory
16 GREYLAG_PROGRAM
= 'python2.5 ../greylag.py'
18 # temporary output file
19 GREYLAG_OUTPUT
= 'tmp-greylag-out.xml'
21 # cd to the test directory, but restore when we're done
22 SAVE_CWD
= os
.getcwd()
24 if os
.path
.exists(GREYLAG_OUTPUT
):
25 os
.remove(GREYLAG_OUTPUT
)
28 if os
.path
.exists(GREYLAG_OUTPUT
):
29 os
.remove(GREYLAG_OUTPUT
)
34 "Run greylag in a subprocess, checking for error return."
35 subprocess
.check_call(("%s -q -o %s %s"
36 % (GREYLAG_PROGRAM
, GREYLAG_OUTPUT
, args
)).split())
38 def run_combination(combination
=None):
39 """Run a greylag test, as specified by combination.
41 If combination is not given, it defaults to the name of the calling
44 For a combination 'greylag_params_0__test_2_test', greylag will be run
45 with a parameter file 'greylag-params-0.xml' and spectrum file
46 'test-2.ms2'. (Additional spectrum files can be specified, separated by
47 '__'.) The results will be compared to 'greylag-params-0--test-2-ok.xml'.
48 If this baseline file is not present and the environment variable
49 NOSEUPDATE is set, a new baseline will be created.
51 if combination
== None:
53 combination
= inspect
.getouterframes(inspect
.currentframe())[1][3]
54 assert combination
.endswith('_test')
55 combination
= combination
.rpartition('_test')[0]
56 parts
= combination
.split('__')
57 params
, spectra
= parts
[0], parts
[1:]
58 assert len(spectra
) >= 1
59 params
= params
.replace('_', '-') + '.xml'
60 spectra
= [ sp
.replace('_', '-') + '.ms2' for sp
in spectra
]
61 correct_fn
= combination
.replace('_', '-') + '-ok.xml'
62 assert os
.path
.exists(correct_fn
) or 'NOSEUPDATE' in os
.environ
, 'no baseline'
63 run_gl(params
+ ' ' + ' '.join(spectra
))
64 if os
.path
.exists(correct_fn
):
65 assert filecmp
.cmp(GREYLAG_OUTPUT
, correct_fn
), 'output differs'
67 os
.rename(GREYLAG_OUTPUT
, correct_fn
)
68 # FIX: now do it in parts, and compare that result
69 # also do it for --quirks?
71 # Could do xtandem and rough compare to quirks? Is this worth doing, since we
72 # can expect at least small differences? Probably we should have a separate
73 # framework for comparing and contrasting output from any two of { greylag,
78 class modless_run_tests
:
79 def greylag_params_0__test_2_test(self
):
81 def greylag_params_0__6323840_test(self
):