Closed slarse closed 4 years ago
One thing to do as well could be to just add an empty file to the invalid test case files
I think I had a reason for not doing that, but I can't recall what it was, so you could try it and see what happens.
Ill keep the test, but this will not be a problem. We run the following code when sanitizing a file:
text = file_abs_path.read_text()
lines = text.split("\n")
So text
becomes an empty string ''
when we sanitize an empty file. Running text.split
on that, however, makes lines
a list containing an empty string ['']
meaning lines[0]
will not break if we have an empty list
Right, that's convenient. Might wanna put in an assert lines
just to clarify that we actually expect it to be non-empty.
It's still a bit of an issue for check_syntax
, however, as it's a public function in its module, and it will crash unexpectedly on being fed an empty list. It could potentially lead to unexpected issues down the line.
A test just for
check_syntax
, which tests the corner case of an empty list (which corresponds to an empty file).