def test_count_words_without_punt(self):
     string = "Los chicos de mi clase estudian ingles, los chicos de segundo frances, y los chicos de tercero italiano."
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('chicos', 3), ('italiano', 1),
                                         ('tercero', 1), ('frances', 1),
                                         ('segundo', 1), ('ingles', 1),
                                         ('estudian', 1), ('clase', 1)])
Ejemplo n.º 2
0
 def test_concat_3strings(self):
     strings = []
     strings.append("hola")
     strings.append("adios")
     strings.append("hola")
     result = StringsExamples.concat_strings(strings)
     assert result == "holaadioshola"
 def test_count_words_without_art(self):
     string = "El perro perro de mi primo es de color marron"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('perro', 2), ('marron', 1),
                                         ('color', 1), ('es', 1),
                                         ('primo', 1)])
 def test_count_words_without_prep(self):
     string = "El coche coche se dirige hacia el colegio"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('coche', 2), ('colegio', 1),
                                         ('dirige', 1)])
Ejemplo n.º 5
0
 def test_get_first_string_from_internet_when_an_error_appears(
         self, mock_urlopen):
     a = Mock()
     a.read.side_effect = ValueError('a')
     mock_urlopen.return_value = a
     self.assertRaises(ValueError, StringsExamples.get_first_string())
 def test_count_words_in_normal_text(self):
     string = "hola me llamo juan hola"
     result = StringsExamples.count_words(string)
     assert result == [('hola', 2), ('juan', 1), ('llamo', 1)]
 def test_count_words_with_rare_caracters_two(self):
     string = "  EL texto    (TiEnE .carateres    raROS  "
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('raros', 1), ('carateres', 1),
                                         ('tiene', 1), ('texto', 1)])
Ejemplo n.º 8
0
import sys
from sample.strings_example import StringsExamples

if __name__ == "__main__":
    args = sys.argv[1:]
    print("Concat strings %s %s..." % (args[0], args[1]))
    concated_strings = StringsExamples.concat_strings(args[0], args[1])
 def test_count_words_end_with_space(self):
     string = "La prueba de que el texto termine por un espacio espacio "
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('espacio', 2), ('termine', 1),
                                         ('texto', 1), ('prueba', 1)])
 def test_normal_text(self):
     string = "hola me llamo juan"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('juan', 1), ('llamo', 1),
                                         ('hola', 1)])
Ejemplo n.º 11
0
import sys
from sample.strings_example import StringsExamples

if __name__ == "__main__":
    args = sys.argv[1:]
    print StringsExamples.concat_strings(args)
 def test_count_words_without_pron(self):
     string = "Aquellos chicos juegan al futbol, mientras que esos chicos a las canicas"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('chicos', 2), ('canicas', 1),
                                         ('mientras', 1), ('futbol', 1),
                                         ('juegan', 1)])
Ejemplo n.º 13
0
 def test_concat_string5_6(self):
     str1 = "aaaa"
     str2 = "bbbbbb"
     result = StringsExamples.concat_strings(str1, str2)
     assert result == "aaaabbbbbb"
Ejemplo n.º 14
0
 def test_concat_string1_1(self):
     str1="a"
     str2 = "b"
     result = StringsExamples.concat_strings(str1,str2)
     assert result=="ab"
Ejemplo n.º 15
0
 def test_concat_two_strings(self):
     str1= "Espana"
     str2= "Belgica"
     result = StringsExamples.concat_strings(str1, str2)
     assert result == "EspanaBelgica"
 def test_count_words_with_rare_caracters(self):
     string = "El texto .. .tiene .carateres !raros"
     result = StringsExamples.count_words(string)
     assert result == [('raros', 1), ('carateres', 1), ('tiene', 1),
                       ('texto', 1)]
 def test_count_words_start_with_space(self):
     string = " La prueba de que el texto empiece por un espacio espacio"
     result = StringsExamples.count_words(string)
     assert result == [('espacio', 2), ('empiece', 1), ('texto', 1),
                       ('prueba', 1)]
Ejemplo n.º 18
0
 def test_concat_string_with_space_begining_end(self):
     strings = []
     strings.append(" hola ")
     strings.append("adios")
     result = StringsExamples.concat_strings(strings)
     assert result == "holaadios"
Ejemplo n.º 19
0
 def test_concat_string_with_number_and_space(self):
     strings = []
     strings.append("hola 123")
     strings.append("adios")
     result = StringsExamples.concat_strings(strings)
     assert result == "hola123adios"
 def test_count_words_more_than_one_space(self):
     string = "La prueba    de         que  el    texto    tenga  mas de un           espacio                espacio"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('espacio', 2), ('tenga', 1),
                                         ('texto', 1), ('prueba', 1)])
 def test_only_stopwords(self):
     string = "pero"
     result = StringsExamples.count_words(string)
     print(result)
     assert result == []
 def test_count_words_with_rare_caracters(self):
     string = "El * texto tiene carateres raros"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('raros', 1), ('carateres', 1),
                                         ('tiene', 1), ('texto', 1)])
 def test_upper_text(self):
     string = "HOLA ME LLAMO JUAN"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('juan', 1), ('llamo', 1),
                                         ('hola', 1)])
 def test_no_countain(self):
     string = ""
     result = StringsExamples.count_words(string)
     assert result == []
 def test_upper_with_lower_text(self):
     string = "HoLa Me LlAmo JuaN"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('juan', 1), ('llamo', 1),
                                         ('hola', 1)])
Ejemplo n.º 26
0
 def test_get_first_string_from_internet(self, mock_urlopen):
     a = Mock()
     a.read.side_effect = ["hello good bye"]
     mock_urlopen.return_value = a
     assert StringsExamples.get_first_string() == "hello"
 def test_count_words_in_upper_text(self):
     string = "HoLa hOlA mE LlaMo JuAn"
     result = StringsExamples.count_words(string)
     assert StringsExamples.cmp(result, [('hola', 2), ('juan', 1),
                                         ('llamo', 1)])
Ejemplo n.º 28
0
 def test_concat_strings(self):
     string1 = "hola"
     string2 = "adios"
     result = StringsExamples.concat_strings(string1, string2)
     assert result == "holaadios"
Ejemplo n.º 29
0
import sys
from sample.strings_example import StringsExamples

if __name__ == "__main__":
    args = sys.argv[1:]
    print (StringsExamples.count_words(args[0]))