Exemple #1
0
    def testEmptyFile(self):
        '''
        if the file is empty assumes empty list returned
        '''
        open(self.filename, "w").close()

        assert bot.load_black_list(self.filename) == []
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
    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
Exemple #5
0
 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)