コード例 #1
0
ファイル: test_utils.py プロジェクト: yinglang/conda
 def test_logs_file_to_debug_log(self):
     random_file = "/some/path/to/a/file/%s" % random.randint(100, 200)
     with create_mock_open() as o:
         o.side_effect = IOError
         with mock.patch.object(utils, "stderrlog") as log:
             utils.can_open(random_file)
     log.info.assert_called_with("Unable to open %s\n" % random_file)
コード例 #2
0
ファイル: test_utils.py プロジェクト: Bbouley/conda
 def test_closes_file_handler_if_successful(self):
     with create_mock_open() as o:
         utils.can_open("/some/file")
     o.assert_has_calls([
         mock.call("/some/file", "ab"),
         mock.call().close(),
     ])
コード例 #3
0
 def test_closes_file_handler_if_successful(self):
     with create_mock_open() as o:
         utils.can_open("/some/file")
     o.assert_has_calls([
         mock.call("/some/file", "ab"),
         mock.call().close(),
     ])
コード例 #4
0
 def test_logs_file_to_debug_log(self):
     random_file = "/some/path/to/a/file/%s" % random.randint(100, 200)
     with create_mock_open() as o:
         o.side_effect = IOError
         with mock.patch.object(utils, "log") as log:
             utils.can_open(random_file)
     log.debug.assert_called_with("Unable to open %s" % random_file)
コード例 #5
0
ファイル: test_utils.py プロジェクト: yinglang/conda
 def test_returns_false_if_unable_to_open(self):
     with create_mock_open() as o:
         o.side_effect = IOError
         self.assertFalse(utils.can_open("/some/path/some/file"))
コード例 #6
0
ファイル: test_utils.py プロジェクト: yinglang/conda
 def test_returns_true_if_can_open(self):
     with create_mock_open():
         self.assertTrue(utils.can_open("/some/path/some/file"))
コード例 #7
0
 def test_returns_false_if_unable_to_open(self):
     with create_mock_open() as o:
         o.side_effect = IOError
         self.assertFalse(utils.can_open("/some/path/some/file"))
コード例 #8
0
 def test_returns_true_if_can_open(self):
     with create_mock_open():
         self.assertTrue(utils.can_open("/some/path/some/file"))