def testEmptyFile(self): ''' if the file is empty assumes empty list returned ''' open(self.filename, "w").close() assert bot.load_black_list(self.filename) == []
def testSimpleLoading(self): ''' writes some sample data to the file then tries loading it out ''' black_list = ['TEST', 'DATA'] bot.save_black_list(self.filename, black_list) assert bot.load_black_list(self.filename) == black_list
def testAppendBlackList(self): ''' test the ability to append an item to the black_list ''' black_list = ['SOME', 'EXAMPLE', 'STRINGS'] for item in black_list: bot.append_to_black_list(self.filename, item) assert bot.load_black_list(self.filename) == black_list
def testLotsOfStrings(self, strings): ''' tests a bunch of generated strings ''' # Assume the list is non-empty. hypothesis.assume(len(strings) > 0) # Fetch the given filename. filename = self.filename for ID in strings: # No whitespace on ends hypothesis.assume(ID.strip() == ID) # Assume no whitespace in middle of string hypothesis.assume(ID.split() == [ID]) # Append the black id to the black_list file bot.append_to_black_list(filename, ID) # Verify that the loaded data matches the input data assert bot.load_black_list(filename) == strings
def testNonExistentFile(self): ''' makes sure that an IOError is raised when the file does not exist ''' with pytest.raises(IOError): bot.load_black_list(self.filename)