-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest_path_helper.py
More file actions
36 lines (26 loc) · 879 Bytes
/
Copy pathtest_path_helper.py
File metadata and controls
36 lines (26 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""Unittest of Path Helper"""
from pathlib import Path
import unittest
from unittest.mock import patch
# custom imports
from path_helper import PathHelper
class TestPathHelper(unittest.TestCase):
def setUp(self) -> None:
pass
def tearDown(self) -> None:
pass
def test_exists(self) -> None:
"""Test existance of file at given path"""
with patch.object(Path, 'exists') as mock_exists:
# mock file existance
mock_exists.return_value = True
result = PathHelper.exists(path='/some/path')
self.assertTrue(result)
# mock file unexistance
mock_exists.return_value = False
result = PathHelper.exists(path='/some/path')
self.assertFalse(result)
if __name__ == '__main__':
unittest.main()