File: testparseversions.py

package info (click to toggle)
python-support 1.0.10
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 232 kB
  • ctags: 125
  • sloc: python: 717; perl: 248; sh: 31; makefile: 19
file content (31 lines) | stat: -rwxr-xr-x 1,089 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python

import unittest
import subprocess

class TestParseVersions(unittest.TestCase):
    def get_output(self, control):
        subp = subprocess.Popen(["parseversions", "--pycentral", control],
                                stdout=subprocess.PIPE)
        output = subp.communicate()[0]
        if subp.returncode != 0:
            raise RuntimeError, subp.returncode
        return output

    def test_regular(self):
        self.assertEqual(self.get_output('testparseversions.regular.control'), '2.6\n')

    def test_leading_newline(self):
        self.assertEqual(self.get_output('testparseversions.leading-newline.control'), '2.6\n')

    def test_missing(self):
        self.assertRaises(RuntimeError, self.get_output, 'testparseversions.missing.control')

    def test_second_paragraph(self):
        self.assertRaises(RuntimeError, self.get_output, 'testparseversions.second-paragraph.control')

    def test_spaces(self):
        self.assertRaises(RuntimeError, self.get_output, 'testparseversions.spaces.control')

if __name__ == '__main__':
    unittest.main()