Package jptests
[hide private]
[frames] | no frames]

Source Code for Package jptests

 1  """Unit tests for the Jazz Parser. 
 2   
 3  This package contains all unit tests for the Jazz Parser. 
 4  A library of unit tests should be gradually built up in here and should  
 5  mirror the package structure of the codebase in the jazzparser package,  
 6  to keep it clear where tests for everything are to be found. 
 7   
 8  At the time of writing, not many tests exist and will almost certainly  
 9  never get round to writing tests for large parts of the codebase.  
10  However, there are some parts that are used particularly frequently,  
11  so I will try to write tests for these first (data structures, utils  
12  modules, etc). These are also expected to maintain their interface,  
13  or at least something backward compatible, most of the time, so  
14  it shouldn't be too big a job to rewrite the tests if they change. 
15   
16  For scripts for running the tests, see C{bin/tests}. 
17   
18  Notes 
19  ===== 
20   
21   1. I've not used the test_*.py naming convention, since the tests are all in a  
22    separate code tree, so there's no real need. The scripts for running the tests 
23    take care of all these sorts of things, so it's best to use them to run tests. 
24   
25   2. Some tests are for things in a module's __init__.py. Although I'm in most  
26    cases mirroring the package structure of the code in the test code, in these  
27    cases I call the test files init.py. If they're called __init__.py they get  
28    discovered twice by unittest: once as the package import and once as the  
29    __init__.py file itself. 
30   
31  """ 
32  """ 
33  ============================== License ======================================== 
34   Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding 
35    
36   This file is part of The Jazz Parser. 
37    
38   The Jazz Parser is free software: you can redistribute it and/or modify 
39   it under the terms of the GNU General Public License as published by 
40   the Free Software Foundation, either version 3 of the License, or 
41   (at your option) any later version. 
42    
43   The Jazz Parser is distributed in the hope that it will be useful, 
44   but WITHOUT ANY WARRANTY; without even the implied warranty of 
45   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
46   GNU General Public License for more details. 
47    
48   You should have received a copy of the GNU General Public License 
49   along with The Jazz Parser.  If not, see <http://www.gnu.org/licenses/>. 
50   
51  ============================ End license ====================================== 
52   
53  """ 
54  __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"  
55   
56   
57 -def prepare_db_input():
58 """ 59 Loads a sequence index file, pulls out some data and prepares it 60 as it using it as input to the parser. 61 62 This may be used by tests to get hold of data as example input. 63 64 @note: Don't rely on the size of the returned tuple to stay the 65 same. I may add more return items in the future, so access the 66 ones that are being returned currently by index. 67 68 @rtype: tuple 69 @return: (sequence index, sequence, DbInput instance) 70 71 """ 72 from jazzparser.data.db_mirrors import SequenceIndex 73 from jazzparser.data.input import DbInput 74 from jazzparser.settings import TEST as settings 75 76 seqs = SequenceIndex.from_file(settings.SEQUENCE_DATA) 77 seq = seqs.sequences[0] 78 79 input_sequence = DbInput.from_sequence(seq) 80 81 return seqs, seq, input_sequence
82