Fix WinProcess.is_exit + test case

This commit is contained in:
hakril
2016-01-19 23:50:10 +01:00
parent fad8121cbf
commit f43f7c4838
2 changed files with 12 additions and 5 deletions
+11 -4
View File
@@ -44,21 +44,21 @@ else:
@contextmanager
def Calc64():
def Calc64(exit_code=0):
try:
calc = pop_calc_64()
yield calc
finally:
calc.exit()
calc.exit(exit_code)
@contextmanager
def Calc32():
def Calc32(exit_code=0):
try:
calc = pop_calc_32()
yield calc
finally:
calc.exit()
calc.exit(exit_code)
class WindowsTestCase(unittest.TestCase):
@@ -285,6 +285,13 @@ class WindowsTestCase(unittest.TestCase):
cont = t.context
self.assertEqual(cont.Rax, 0x4242424243434343)
def test_process_is_exit(self):
with Calc32(exit_code=42) as calc:
self.assertEqual(calc.is_exit, False)
# out of context manager: process is exit
self.assertEqual(calc.exit_code, 42)
self.assertEqual(calc.is_exit, True)
class WindowsAPITestCase(unittest.TestCase):
def test_createfileA_fail(self):
with self.assertRaises(WindowsError) as ar:
+1 -1
View File
@@ -311,7 +311,7 @@ class Process(AutoHandle):
:type: :class:`bool`
"""
return self.exit_code == STILL_ACTIVE
return self.exit_code != STILL_ACTIVE
def execute(self, code):
"""Execute some native code in the context of the process