예제 #1
0
 def test_mkdir_exists_but_is_directory(self):
     p = unittest.mock.Mock()
     p.is_dir.return_value = True
     p.mkdir.side_effect = FileExistsError()
     utils.mkdir_exist_ok(p)
     self.assertSequenceEqual(p.mock_calls, [
         unittest.mock.call.mkdir(parents=True),
         unittest.mock.call.is_dir()
     ])
예제 #2
0
 def test_successful_mkdir(self):
     p = unittest.mock.Mock()
     utils.mkdir_exist_ok(p)
     self.assertSequenceEqual(
         p.mock_calls,
         [
             unittest.mock.call.mkdir(parents=True),
         ]
     )
 def test_successful_mkdir(self):
     p = unittest.mock.Mock()
     utils.mkdir_exist_ok(p)
     self.assertSequenceEqual(
         p.mock_calls,
         [
             unittest.mock.call.mkdir(parents=True),
         ]
     )
예제 #4
0
 def test_mkdir_exists_but_is_directory(self):
     p = unittest.mock.Mock()
     p.is_dir.return_value = True
     p.mkdir.side_effect = FileExistsError()
     utils.mkdir_exist_ok(p)
     self.assertSequenceEqual(
         p.mock_calls,
         [
             unittest.mock.call.mkdir(parents=True),
             unittest.mock.call.is_dir()
         ]
     )
예제 #5
0
    def test_mkdir_exists_but_is_not_directory(self):
        p = unittest.mock.Mock()
        p.is_dir.return_value = False
        exc = FileExistsError()
        p.mkdir.side_effect = exc
        with self.assertRaises(FileExistsError) as ctx:
            utils.mkdir_exist_ok(p)

        self.assertIs(ctx.exception, exc)

        self.assertSequenceEqual(p.mock_calls, [
            unittest.mock.call.mkdir(parents=True),
            unittest.mock.call.is_dir()
        ])
예제 #6
0
    def test_mkdir_exists_but_is_not_directory(self):
        p = unittest.mock.Mock()
        p.is_dir.return_value = False
        exc = FileExistsError()
        p.mkdir.side_effect = exc
        with self.assertRaises(FileExistsError) as ctx:
            utils.mkdir_exist_ok(p)

        self.assertIs(ctx.exception, exc)

        self.assertSequenceEqual(
            p.mock_calls,
            [
                unittest.mock.call.mkdir(parents=True),
                unittest.mock.call.is_dir()
            ]
        )