def test_get_system_time(self): ''' Test to get system time ''' mock = MagicMock(return_value="11:31:15 AM") with patch.dict(win_system.__salt__, {'cmd.run': mock}): self.assertEqual(win_system.get_system_time(), '11:31:15 AM')
def test_get_system_time(self): ''' Test to get system time ''' tm = datetime.strftime(datetime.now(), "%I:%M %p") win_tm = win_system.get_system_time() try: self.assertEqual(win_tm, tm) except AssertionError: # handle race condition import re self.assertTrue(re.search(r'^\d{2}:\d{2} \w{2}$', win_tm))