| Total Complexity | 8 |
| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import os |
||
| 10 | class TestFileExists(unittest.TestCase): |
||
| 11 | |||
| 12 | def setUp(self): |
||
| 13 | with NamedTemporaryFile(prefix='mocke_', suffix='.txt', |
||
| 14 | delete=False) as tmp: |
||
| 15 | with open(tmp.name, 'w') as fp: |
||
| 16 | fp.write('121XZTT') |
||
| 17 | |||
| 18 | self.tmp_path = tmp.name |
||
| 19 | |||
| 20 | def test_file_exists(self): |
||
| 21 | self.assertTrue(file_exists(self.tmp_path)) |
||
| 22 | |||
| 23 | def test_not_exists(self): |
||
| 24 | file_name = str(uuid4()) + '.txt' |
||
| 25 | |||
| 26 | with self.assertRaises(FileExistsError): |
||
| 27 | file_exists(file_name) |
||
| 28 | |||
| 29 | def tearDown(self): |
||
| 30 | if os.path.exists(self.tmp_path): |
||
| 31 | os.unlink(self.tmp_path) |
||
| 32 | |||
| 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.