annotate tests/test_fail.py @ 3:d3a4f7b41944

add a stub test
author Jeff Hammel <k0scist@gmail.com>
date Tue, 23 Aug 2016 15:39:06 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 """
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 unit tests for fail
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 """
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 # imports
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 import os
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 import subprocess
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 import sys
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 import tempfile
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 import unittest
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 # module globals
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 here = os.path.dirname(os.path.abspath(__file__))
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 fail_command = 'fail'
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 class FailUnitTest(unittest.TestCase):
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 def test_subprocess(self):
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 """test fail invocation"""
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23 process = subprocess.Popen([fail_command, 'false'])
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24 process.communicate()
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 self.assertEqual(process.returncode, 1)
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27 if __name__ == '__main__':
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28 unittest.main()
d3a4f7b41944 add a stub test
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
29