From f43f7c4838887df45afacf62a46adf6b6902e674 Mon Sep 17 00:00:00 2001 From: hakril Date: Tue, 19 Jan 2016 23:50:10 +0100 Subject: [PATCH] Fix WinProcess.is_exit + test case --- windows/test/mytest.py | 15 +++++++++++---- windows/winobject.py | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/windows/test/mytest.py b/windows/test/mytest.py index 153300c..9701e5a 100644 --- a/windows/test/mytest.py +++ b/windows/test/mytest.py @@ -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: diff --git a/windows/winobject.py b/windows/winobject.py index 72a95c2..92752d9 100644 --- a/windows/winobject.py +++ b/windows/winobject.py @@ -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