def test_commit(data, expected_date, is_pass): if not is_pass: with pytest.raises(Exception) as e_info: # Expecting an exception commit = Commit(data) commit.get_date() else: # Shouldn't get an exception commit = Commit(data) assert commit.get_date() == expected_date, "Date or the format did not match " \ "the expected date: %s" % expected_date