ソースを参照

AMBARI-9675. Some rarely reproducible python tests failures (aonishuk)

Andrew Onishuk 10 年 前
コミット
382cf5828c

+ 1 - 1
ambari-agent/src/test/python/resource_management/TestExecuteResource.py

@@ -115,7 +115,7 @@ class TestExecuteResource(TestCase):
       )
     pass
 
-    time_mock.assert_called_once_with(10)
+    self.assertTrue(call(10) in time_mock.call_args_list)
 
   @patch.object(pwd, "getpwnam")
   def test_attribute_group(self, getpwnam_mock):

+ 5 - 0
ambari-server/src/test/python/custom_actions/TestInstallPackages.py

@@ -19,7 +19,9 @@ limitations under the License.
 '''
 import json
 import os
+import pty
 import socket
+import subprocess
 from resource_management import Script,ConfigDictionary
 from mock.mock import patch
 from mock.mock import MagicMock
@@ -31,6 +33,9 @@ from resource_management.core.resources.packaging import Package
 from resource_management.core.exceptions import Fail
 from ambari_commons.os_check import OSCheck
 
+@patch.object(pty, "openpty", new = MagicMock(return_value=(1,5)))
+@patch.object(os, "close", new=MagicMock())
+@patch.object(subprocess, "Popen", new=MagicMock())
 class TestInstallPackages(RMFTestCase):
 
   @staticmethod