-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_input_output.py
More file actions
36 lines (26 loc) · 1.28 KB
/
test_input_output.py
File metadata and controls
36 lines (26 loc) · 1.28 KB
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
"""
Run the tests by executing, for all test classes:
$ python -m unittest -v test_input_output.py
or
$ python test_input_output.py
"""
import unittest
from input_output import save_as_ply
from typing import Final
class Test_save_as_ply(unittest.TestCase):
def test_GivenNoParameters_When_save_as_play_ThenExceptionIsRaised(self):
self.assertRaises(TypeError, save_as_ply)
def test_GivenAnNonexistentInputFile_When_save_as_play_ThenExceptionIsRaised(self):
nonexistent_file_in_xyx: Final = 'data/this-file-does-not-exist'
filename_out_ply: Final = "data/out.ply"
self.assertRaises(IOError, save_as_ply, nonexistent_file_in_xyx, filename_out_ply)
def test_GivenAnEmptyInputFile_When_save_as_play_ThenExceptionIsRaised(self):
empty_file_in_xyx: Final = 'data/empty-file'
filename_out_ply: Final = "data/out.ply"
self.assertRaises(ValueError, save_as_ply, empty_file_in_xyx, filename_out_ply)
def test_GivenAFaultyInputFile_When_save_as_play_ThenExceptionIsRaised(self):
faulty_file_in_xyx: Final = 'data/points-in--faulty.xyz'
filename_out_ply: Final = "data/out.ply"
self.assertRaises(ValueError, save_as_ply, faulty_file_in_xyx, filename_out_ply)
if __name__ == '__main__':
unittest.main()