コード例 #1
0
    def test_count_strings(self):
        text = ("verano verano verano primavera primavera primavera "
                "invierno invierno invierno")
        solution = [('verano', 3), ('primavera', 3), ('invierno', 3)]

        result, words, set_words = StringsCounter.count_strings(text)

        assert collections.Counter(result) == collections.Counter(solution)
        assert words == 9
        assert set_words == 3
コード例 #2
0
 def test_check_several_strings_are_the_same(self):
     text = ("hola caracola, esto es un texto de prueba!!")
     solution = ['hola', 'caracola', 'esto', 'texto', 'de', 'prueba']
     result = StringsCounter.count_strings(text)
     same = True
     for i in range(0, len(solution)):
         if result[i][0] not in solution == True:
             same = False
             break
     assert same
コード例 #3
0
 def test_numbers_in_string(self):
     text = ("1 4m 4 133t h4ck3r")
     solution = [('4m', 1), ('133t', 1), ('h4ck3r', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #4
0
 def test_strings_are_more_than_1_char(self):
     text = ("a b cd efg h i jk")
     solution = [('cd', 1), ('efg', 1), ('jk', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #5
0
 def test_numbers_without_string(self):
     text = ("1 2 3")
     solution = []
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #6
0
 def test_method_clear_punctiation_symbols_at_end_of_string(self):
     word = "Hola?"
     solution = "Hola"
     result = StringsCounter.clear_punctiation_symbols(word)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #7
0
 def test_empty_text(self):
     text = ("")
     solution = []
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #8
0
 def test_punctuation_symbol_with_string(self):
     text = ("Hola...")
     solution = [('hola', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #9
0
 def test_method_clear_stopword(self):
     word = "aquel"
     solution = ""
     result = StringsCounter.clear_stopwords(word)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #10
0
 def test_varias_siglas_con_strings(self):
     text = ("la C.I.A esta trabajando con la N.A.S.A")
     solution = [('nasa', 1), ('trabajando', 1), ('cia', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #11
0
 def test_unicode_diferentes(self):
     text = ("❤ ☢ ❤ ☢")
     solution = []
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #12
0
 def test_sigla_unica(self):
     text = ("C.I.A")
     solution = [('cia', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #13
0
 def test_varias_siglas(self):
     text = ("C.I.A  N.A.S.A")
     solution = [('cia', 1), ('nasa', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #14
0
 def test_correct_order(self):
     text = ("hola hola hola adios adios buenas")
     solution = [('hola', 3), ('adios', 2), ('buenas', 1)]
     assert solution == StringsCounter.count_strings(text)
コード例 #15
0
 def test_different_capital_letters_same_number(self):
     text = ("HoLA hola HOLA")
     solution = [('holi', 3)]
     assert solution[0][1] == StringsCounter.count_strings(text)[0][1]
コード例 #16
0
 def test_meter_numeros_String(self):
     text = ("1 2 3 1 2 3 1 2 3 4 alvaro 6")
     solution = [('alvaro', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #17
0
 def test_punctuation_symbol_alone(self):
     text = (". . .")
     solution = []
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #18
0
 def test_unicode_string(self):
     text = ("las armas ☢ son peligrosas")
     solution = [('armas', 1), ('son', 1), ('peligrosas', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #19
0
 def test_count_strings(self):
     text = ("verano verano verano")
     solution = [('verano', 3)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #20
0
 def test_count_varios_Strings(self):
     text = ("verano verano verano primavera primavera primavera "
             "invierno invierno invierno")
     solution = [('verano', 3), ('primavera', 3), ('invierno', 3)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #21
0
 def test_punctuation_symbol_with_strings_of_diferent_lenght(self):
     text = ("a... bc! def??")
     solution = [('bc', 1), ('def', 1)]
     result = StringsCounter.count_strings(text)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #22
0
import sys
from sample.strings_counter import StringsCounter

if __name__ == "__main__":
    args = sys.argv[1:]
    #Esto imprimira el resultado de forma bonita
    dic, words, set_words = StringsCounter.count_strings(args)
    StringsCounter.print_solution(dic, words, set_words)
コード例 #23
0
 def test_method_clear_punctiation_symbols_alone(self):
     word = "!"
     solution = ""
     result = StringsCounter.clear_punctiation_symbols(word)
     assert collections.Counter(result) == collections.Counter(solution)
コード例 #24
0
 def test_count_words(self):
     word = "Hola"
     text = ['Hola', 'Hola', 'Hola']
     solution = 3
     result = StringsCounter.count_words(word, text)
     assert result == solution
コード例 #25
0
 def test_check_one_string_is_the_same(self):
     text = ("hola")
     solution = ['hola']
     result = StringsCounter.count_strings(text)
     assert result[0][0] == solution[0]
コード例 #26
0
 def test_count_words_uneven_text(self):
     word = "Hola"
     text = ['Hola', 'este', 'texto', 'es', 'de', 'prueba', 'Hola']
     solution = 2
     result = StringsCounter.count_words(word, text)
     assert result == solution
コード例 #27
0
import sys
from sample.strings_counter import StringsCounter

if __name__ == "__main__":
    args = sys.argv[1:]
    #Esto imprimira el resultado de forma bonita
    dic = StringsCounter.count_strings(args)
    StringsCounter.print_solution(dic)
コード例 #28
0
 def test_method_clear_punctiation_symbols_inside_string(self):
     word = "H<o.l;a)"
     solution = "Hola"
     result = StringsCounter.clear_punctiation_symbols(word)
     assert collections.Counter(result) == collections.Counter(solution)