def test_comments_and_blank_lines_are_stripped_out(self, mocker): contents = [ "# Here is a comment on the first line", "# Here is another comment. The next line is just whitespace", "\t\t\t\t\t", "", "_some_normal_line previous_line_was_blank", " _another_normal_line starting_with_whitespace", '# Final comment ## with # extra hashes ### in ##' ] mocker.patch("builtins.open", mock.mock_open(read_data='\n'.join(contents))) expected_remaining_lines = contents[4:6] p = CIFParser("/some_directory/some_file.cif") p._strip_comments_and_blank_lines() assert p.raw_data == "\n".join(expected_remaining_lines)