]> git.decadent.org.uk Git - dak.git/blob - dak/test/003/test.py
Add a 'fixture' utility to generate a path to a fixture.
[dak.git] / dak / test / 003 / test.py
1 #!/usr/bin/env python
2
3 # Check utils.parse_changes()'s for handling of multi-line fields
4 # Copyright (C) 2000, 2006  James Troup <james@nocrew.org>
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20 ################################################################################
21
22 # The deal here is that for the first 6 months of dak's
23 # implementation it has been misparsing multi-line fields in .changes
24 # files; specifically multi-line fields where there _is_ data on the
25 # first line. So, for example:
26
27 # Foo: bar baz
28 #  bat bant
29
30 # Became "foo: bar bazbat bant" rather than "foo: bar baz\nbat bant"
31
32 ################################################################################
33
34 import os, sys
35
36 sys.path.append(os.path.abspath('../../'))
37
38 import utils
39
40 ################################################################################
41
42 def fail(message):
43     sys.stderr.write("%s\n" % (message))
44     sys.exit(1)
45
46 ################################################################################
47
48 def main ():
49     # Valid .changes file with a multi-line Binary: field
50     try:
51         changes = utils.parse_changes('krb5_1.2.2-4_m68k.changes', 0)
52     except utils.changes_parse_error_exc, line:
53         fail("parse_changes() returned an exception with error message `%s'." % (line))
54
55     o = changes.get("binary", "")
56     if o != "":
57         del changes["binary"]
58     changes["binary"] = {}
59     for j in o.split():
60         changes["binary"][j] = 1
61
62     if not changes["binary"].has_key("krb5-ftpd"):
63         fail("parse_changes() is broken; 'krb5-ftpd' is not in the Binary: dictionary.")
64
65 ################################################################################
66
67 if __name__ == '__main__':
68     main()