[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Mocking issues with unit test for tasklist



commit ff8de9372ec6d4fa47949f0b171a0c58b0aa1440
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Feb 17 09:51:14 2015 -0800

    Mocking issues with unit test for tasklist
    
    We didn't pretend to be on windows so this was skipped on other platforms, and
    returned the tasklist results for *any* call() invocation (not just the one for
    tasklist). Unit tests now pass for me.
---
 test/unit/util/system.py |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/unit/util/system.py b/test/unit/util/system.py
index b733769..f6e9f35 100644
--- a/test/unit/util/system.py
+++ b/test/unit/util/system.py
@@ -267,12 +267,13 @@ class TestSystem(unittest.TestCase):
 
   @patch('stem.util.system.call')
   @patch('stem.util.system.is_available', Mock(return_value = True))
+  @patch('stem.util.system.is_windows', Mock(return_value = True))
   def test_pid_by_name_tasklist(self, call_mock):
     """
     Tests the pid_by_name function with tasklist responses.
     """
 
-    call_mock.return_value = GET_PID_BY_NAME_TASKLIST_RESULTS
+    call_mock.side_effect = mock_call('tasklist', GET_PID_BY_NAME_TASKLIST_RESULTS)
     self.assertEqual(3712, system.pid_by_name('tor'))
     self.assertEqual(None, system.pid_by_name('DirectoryService'))
     self.assertEqual(None, system.pid_by_name('blarg'))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits