35 lines
723 B
Python
Executable File
35 lines
723 B
Python
Executable File
import unittest
|
|
import job
|
|
|
|
class Mock_Subprocess() :
|
|
called = False
|
|
joined = False
|
|
pid = None
|
|
def __init__(self) :
|
|
pass
|
|
|
|
def call(self, *args, **kwargs) :
|
|
self.called = True
|
|
|
|
def join(self, *args, **kwargs) :
|
|
self.joined = True
|
|
|
|
class Test_Job(unittest.TestCase):
|
|
def setUp(self) :
|
|
self.was = job.subprocess
|
|
self.subprocess = Mock_Subprocess()
|
|
job.subprocess = self.subprocess
|
|
|
|
def tearDown(self) :
|
|
job.subprocess = self.was
|
|
|
|
def test(self) :
|
|
p = Mock_Subprocess()
|
|
j = job.Job("id", p)
|
|
j.kill()
|
|
self.assertEqual(p.joined, True)
|
|
self.assertEqual(self.subprocess.called, True)
|
|
|
|
if __name__ == "__main__" :
|
|
unittest.main()
|