Skip to content
Snippets Groups Projects
Select Git revision
  • f6b348da59718ca691d93a50711d3b7622c8d1df
  • master default
2 results

TEST.py

Blame
  • Forked from Brady James Garvin / sentiment
    5 commits behind, 4 commits ahead of the upstream repository.
    TEST.py 2.97 KiB
    from unittest import TestCase
    import sentiment
    
    
    class TestPreloading(TestCase):
        def test_preloading(self):
            example = ['3 In its own floundering way , it gets to you .', '3 Audacious-impossible yet compelling .']
            self.assertEquals(sentiment.preloading(example), (
            {',': ['3'], '.': ['3', '3'], 'Auda3cious-impossible': ['3'], 'In': ['3'], 'compelling': ['3'],
             'floundering': ['3'], 'gets': ['3'], 'it': ['3'], 'its': ['3'], 'own': ['3'], 'to': ['3'], 'way': ['3'],
             'yet': ['3'], 'you': ['3']}))
    
        def test_2(self):
            example = ['0 never will this fail the testing .']
            self.assertEquals(sentiment.preloading(example), (
            {'testing': ['0'], 'this': ['0'], 'never': ['0'], '.': ['0'], 'will': ['0'], 'fail': ['0'], 'the': ['0']}))
    
    
    
    
        def test_preloading12(self):
            try:
                with open("sentiment.txt") as file:
                    loading = file.read()
                    raw_file = loading.split('\n')
    
            except IOError:
                print("File Not Found")
            review = sentiment.preloading(raw_file)
            average = 0
            number = 0
            average, number =sentiment.option1(review, 'arty')
            self.assertEquals(number, 4)
    
        def test_number_20(self):
            try:
                with open("sentiment.txt") as file:
                    loading = file.read()
                    raw_file = loading.split('\n')
    
            except IOError:
                print("File Not Found")
    
            review = sentiment.preloading(raw_file)
    
            average = 0
            number = 0
            average, number =sentiment.option1(review, 'scramble')
            self.assertEquals(average, None)
    
        def test_number_22(self):
            try:
                with open("sentiment.txt") as file:
                    loading = file.read()
                    raw_file = loading.split('\n')
    
            except IOError:
                print("File Not Found")
    
            review = sentiment.preloading(raw_file)
            average = 0
            number = 0
            positive_word="The most positive word is \" None \" with a score of None\nThe most negative word is \" None \" with a score of None"
            filename= 'positive.txt'
    
            print(positive_word)
            print("here ")
    
            self.assertEquals((sentiment.file_score(review,filename)),(positive_word))
    
        def test_number_24(self):
            # examples.txt has a word called scramble that does not exist in the dictionary and should not be in any
            # of the files
    
            try:
                with open("sentiment.txt") as file:
                    loading = file.read()
                    raw_file = loading.split('\n')
    
            except IOError:
                print("File Not Found")
    
            review = sentiment.preloading(raw_file)
            filename= 'examples.txt'
            positive,negative = sentiment.word_sorting(review,filename)
    
            positive2 = ['has', 'a', 'very', 'and', 'refreshing']
            negative2 = ['This', 'movie', 'bad', 'plot', 'terrible', 'ending', 'horrible']
    
            self.assertEquals((positive, negative),(positive2 , negative2))