def null_arg(): """ Null argument. """ try: _ = participants_parser(None) except AssertionError: print('Exception catched. Great') return 1, 1 else: print('Error: Exception not catched') return 0, 1
def illformated_file(): """ Illformated file. """ try: _ = participants_parser("illformated_test.csv") except ValueError: print('Exception catched. Great') return 1, 1 else: print('Error: Exception not catched') return 0, 1
def no_file(): """ No file on disk. """ try: _ = participants_parser("something_that_does_not_exist") except IOError: print('Exception catched. Great') return 1, 1 else: print('Error: Exception not catched') return 0, 1
def bad_type_arg(): """ Argument is an int not a str. """ try: _ = participants_parser(0) except TypeError: print('Exception catched. Great') return 1, 1 else: print('Error: Exception not catched') return 0, 1
def good(): """ Good test, should work. """ try: participants = participants_parser("test.csv") couples = participants_shuffler(participants) for couple in couples: print(str(couple[0]), '->', str(couple[1])) print("File Parsed. Great.") return 1, 1 except: return 0, 1
def good(): """ Good test, should work. """ try: participants = participants_parser("test.csv") for participant in participants: print(str(participant)) print("File Parsed. Great.") return 1, 1 except: print("Something happened.") return 0, 1
def main(): """ Main function. """ if len(argv) <= 1: raise AssertionError( 'Error: A CSV file containing participants is needed.') if len(argv) > 2: raise AssertionError('Error: A single CSV file is needed.') csv_file = argv[1] if csv_file[-4:] != ".csv": raise AssertionError('Error: The argument might not be a csv file.') participants = participants_parser(csv_file) couples = participants_shuffler(participants) participants_mail(couples)