| Total Complexity | 4 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import os |
||
| 34 | class TestEnsureFiles(unittest.TestCase): |
||
| 35 | |||
| 36 | def setUp(self): |
||
| 37 | self.base_path = mkdtemp() |
||
| 38 | |||
| 39 | def test_ensure_file_directory(self): |
||
| 40 | directory = str(uuid4()) |
||
| 41 | file_name = str(uuid4()) + '.txt' |
||
| 42 | directory_path = os.path.join(self.base_path, directory) |
||
| 43 | path = os.path.join(directory_path, file_name) |
||
| 44 | |||
| 45 | ensure_file_directory(path) |
||
| 46 | |||
| 47 | self.assertTrue(os.path.exists(directory_path)) |
||
| 48 | |||
| 49 | # make sure nothing happens on second call |
||
| 50 | ensure_file_directory(path) |
||
| 51 | |||
| 52 | def tearDown(self): |
||
| 53 | if os.path.exists(self.base_path): |
||
| 54 | shutil.rmtree(self.base_path) |
||
| 55 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.