Example #1
0
def test_spelling_id_multilpe_pwl():
    """
    Test spelling on source messages (English) of gettext files
    using multiple personal word lists.
    """
    po_check = PoCheck()
    pwl_files = [
        local_path('pwl1.txt'),
        local_path('pwl2.txt'),
    ]
    po_check.set_spelling_options('id', None, pwl_files)
    result = po_check.check_files([local_path('fr_spelling_id.po')])

    # be sure we have 1 file in result
    assert len(result) == 1

    # the file has 2 spelling errors: "Thsi" and "errro"
    report = result[0][1]
    assert len(report) == 2
    for i, word in enumerate(('Thsi', 'errro')):
        assert report[i].idmsg == 'spelling-id'
        assert isinstance(report[i].message, list)
        assert len(report[i].message) == 1
        assert report[i].message[0] == word
        assert report[i].get_misspelled_words() == [word]
Example #2
0
def test_spelling_str_multiple_pwl():
    """
    Test spelling on translated messages of gettext files
    using multiple personal word lists.
    """
    po_check = PoCheck()
    pwl_files = [
        local_path('pwl1.txt'),
        local_path('pwl2.txt'),
    ]
    po_check.set_spelling_options('str', None, pwl_files)
    result = po_check.check_files(
        [local_path('fr_spelling_str.po'),
         local_path('fr_language.po')])

    # be sure we have 2 files in result
    assert len(result) == 2

    # first file has 3 spelling errors: "CecX", "aabbcc" and "xxyyzz"
    report = result[0][1]
    assert len(report) == 3
    for i, word in enumerate(('CecX', 'aabbcc', 'xxyyzz')):
        assert report[i].idmsg == 'spelling-str'
        assert isinstance(report[i].message, list)
        assert len(report[i].message) == 1
        assert report[i].message[0] == word
        assert report[i].get_misspelled_words() == [word]

    # second file has 1 error: dict/language "xyz" not found
    report = result[1][1]
    assert len(report) == 1
    assert report[0].idmsg == 'dict'
Example #3
0
    def test_spelling_str_multiple_pwl(self):
        """
        Test spelling on translated messages of gettext files
        using multiple personal word lists.
        """
        po_check = PoCheck()
        pwl_files = [
            local_path('pwl1.txt'),
            local_path('pwl2.txt'),
        ]
        po_check.set_spelling_options('str', None, pwl_files)
        result = po_check.check_files([local_path('fr_spelling_str.po'),
                                       local_path('fr_language.po')])

        # be sure we have 2 files in result
        self.assertEqual(len(result), 2)

        # first file has 3 spelling errors: "CecX", "aabbcc" and "xxyyzz"
        errors = result[0][1]
        self.assertEqual(len(errors), 3)
        for i, word in enumerate(('CecX', 'aabbcc', 'xxyyzz')):
            self.assertEqual(errors[i].idmsg, 'spelling-str')
            self.assertTrue(isinstance(errors[i].message, list))
            self.assertEqual(len(errors[i].message), 1)
            self.assertEqual(errors[i].message[0], word)

        # second file has 1 error: dict/language "xyz" not found
        errors = result[1][1]
        self.assertEqual(len(errors), 1)
        self.assertEqual(errors[0].idmsg, 'dict')
Example #4
0
def test_spelling_str():
    """Test spelling on translated messages of gettext files."""
    po_check = PoCheck()
    pwl_files = [local_path('pwl1.txt')]
    po_check.set_spelling_options('str', None, pwl_files)
    result = po_check.check_files(
        [local_path('fr_spelling_str.po'),
         local_path('fr_language.po')])

    # be sure we have 2 files in result
    assert len(result) == 2

    # first file has 3 spelling errors: "CecX", "aabbcc" and "xxyyzz"
    errors = result[0][1]
    assert len(errors) == 4
    for i, word in enumerate(('testtwo', 'CecX', 'aabbcc', 'xxyyzz')):
        assert errors[i].idmsg == 'spelling-str'
        assert isinstance(errors[i].message, list)
        assert len(errors[i].message) == 1
        assert errors[i].message[0] == word

    # second file has 1 error: dict/language "xyz" not found
    errors = result[1][1]
    assert len(errors) == 1
    assert errors[0].idmsg == 'dict'
Example #5
0
 def test_spelling_bad_pwl(self):
     """Test spelling with a bad pwl option."""
     po_check = PoCheck()
     try:
         po_check.set_spelling_options("str", None, local_path("pwl_does_not_exist.txt"))
     except IOError:
         pass  # this exception is expected
     else:
         self.fail("No problem when using a non-existing pwl file!")
Example #6
0
 def test_spelling_bad_pwl(self):
     """Test spelling with a bad pwl option."""
     po_check = PoCheck()
     try:
         pwl_files = [local_path('pwl_does_not_exist.txt')]
         po_check.set_spelling_options('str', None, pwl_files)
     except IOError:
         pass  # this exception is expected
     else:
         self.fail('No problem when using a non-existing pwl file!')
Example #7
0
 def test_spelling_bad_pwl(self):
     """Test spelling with a bad pwl option."""
     po_check = PoCheck()
     try:
         po_check.set_spelling_options('str', None,
                                       local_path('pwl_does_not_exist.txt'))
     except IOError:
         pass  # this exception is expected
     else:
         self.fail('No problem when using a non-existing pwl file!')
Example #8
0
    def test_spelling_id(self):
        """Test spelling on source messages (English) of gettext files."""
        po_check = PoCheck()
        po_check.set_spelling_options('id', None, local_path('pwl.txt'))
        result = po_check.check_files([local_path('fr_spelling_id.po')])

        # be sure we have 1 file in result
        self.assertEqual(len(result), 1)

        # the file has 2 spelling errors: "Thsi" and "errro"
        errors = result[0][1]
        self.assertEqual(len(errors), 2)
        for i, word in enumerate(('Thsi', 'errro')):
            self.assertEqual(errors[i].idmsg, 'spelling-id')
            self.assertTrue(isinstance(errors[i].message, list))
            self.assertEqual(len(errors[i].message), 1)
            self.assertEqual(errors[i].message[0], word)
Example #9
0
    def test_spelling_id(self):
        """Test spelling on source messages (English) of gettext files."""
        po_check = PoCheck()
        po_check.set_spelling_options("id", None, local_path("pwl.txt"))
        result = po_check.check_files([local_path("fr_spelling_id.po")])

        # be sure we have 1 file in result
        self.assertEqual(len(result), 1)

        # the file has 2 spelling errors: "Thsi" and "errro"
        errors = result[0][1]
        self.assertEqual(len(errors), 2)
        for i, word in enumerate(("Thsi", "errro")):
            self.assertEqual(errors[i].idmsg, "spelling-id")
            self.assertTrue(isinstance(errors[i].message, list))
            self.assertEqual(len(errors[i].message), 1)
            self.assertEqual(errors[i].message[0], word)
Example #10
0
def test_spelling_id():
    """Test spelling on source messages (English) of gettext files."""
    po_check = PoCheck()
    pwl_files = [local_path('pwl1.txt')]
    po_check.set_spelling_options('id', None, pwl_files)
    result = po_check.check_files([local_path('fr_spelling_id.po')])

    # be sure we have 1 file in result
    assert len(result) == 1

    # the file has 2 spelling errors: "Thsi" and "errro"
    errors = result[0][1]
    assert len(errors) == 3
    for i, word in enumerate(('Thsi', 'testtwo', 'errro')):
        assert errors[i].idmsg == 'spelling-id'
        assert isinstance(errors[i].message, list)
        assert len(errors[i].message) == 1
        assert errors[i].message[0] == word
Example #11
0
    def test_spelling_id(self):
        """Test spelling on source messages (English) of gettext files."""
        po_check = PoCheck()
        pwl_files = [local_path('pwl1.txt')]
        po_check.set_spelling_options('id', None, pwl_files)
        result = po_check.check_files([local_path('fr_spelling_id.po')])

        # be sure we have 1 file in result
        self.assertEqual(len(result), 1)

        # the file has 2 spelling errors: "Thsi" and "errro"
        errors = result[0][1]
        self.assertEqual(len(errors), 3)
        for i, word in enumerate(('Thsi', 'testtwo', 'errro')):
            self.assertEqual(errors[i].idmsg, 'spelling-id')
            self.assertTrue(isinstance(errors[i].message, list))
            self.assertEqual(len(errors[i].message), 1)
            self.assertEqual(errors[i].message[0], word)
Example #12
0
    def test_spelling_str(self):
        """Test spelling on translated messages of gettext files."""
        po_check = PoCheck()
        po_check.set_spelling_options("str", None, local_path("pwl.txt"))
        result = po_check.check_files([local_path("fr_spelling_str.po"), local_path("fr_language.po")])

        # be sure we have 2 files in result
        self.assertEqual(len(result), 2)

        # first file has 3 spelling errors: "CecX", "aabbcc" and "xxyyzz"
        errors = result[0][1]
        self.assertEqual(len(errors), 3)
        for i, word in enumerate(("CecX", "aabbcc", "xxyyzz")):
            self.assertEqual(errors[i].idmsg, "spelling-str")
            self.assertTrue(isinstance(errors[i].message, list))
            self.assertEqual(len(errors[i].message), 1)
            self.assertEqual(errors[i].message[0], word)

        # second file has 1 error: dict/language "xyz" not found
        errors = result[1][1]
        self.assertEqual(len(errors), 1)
        self.assertEqual(errors[0].idmsg, "dict")
Example #13
0
    def test_spelling_str(self):
        """Test spelling on translated messages of gettext files."""
        po_check = PoCheck()
        po_check.set_spelling_options('str', None, local_path('pwl.txt'))
        result = po_check.check_files([local_path('fr_spelling_str.po'),
                                       local_path('fr_language.po')])

        # be sure we have 2 files in result
        self.assertEqual(len(result), 2)

        # first file has 3 spelling errors: "CecX", "aabbcc" and "xxyyzz"
        errors = result[0][1]
        self.assertEqual(len(errors), 3)
        for i, word in enumerate(('CecX', 'aabbcc', 'xxyyzz')):
            self.assertEqual(errors[i].idmsg, 'spelling-str')
            self.assertTrue(isinstance(errors[i].message, list))
            self.assertEqual(len(errors[i].message), 1)
            self.assertEqual(errors[i].message[0], word)

        # second file has 1 error: dict/language "xyz" not found
        errors = result[1][1]
        self.assertEqual(len(errors), 1)
        self.assertEqual(errors[0].idmsg, 'dict')
Example #14
0
def test_spelling_bad_pwl():
    """Test spelling with a bad pwl option."""
    po_check = PoCheck()
    with pytest.raises(IOError):
        pwl_files = [local_path('pwl_does_not_exist.txt')]
        po_check.set_spelling_options('str', None, pwl_files)
Example #15
0
def test_spelling_bad_dict():
    """Test spelling with a bad dict option."""
    po_check = PoCheck()
    po_check.set_spelling_options('str', 'xxx', None)
    assert not po_check.extra_checkers
Example #16
0
 def test_spelling_bad_dict(self):
     """Test spelling with a bad dict option."""
     po_check = PoCheck()
     po_check.set_spelling_options('str', 'xxx', None)
     self.assertEqual(len(po_check.extra_checkers), 0)
Example #17
0
 def test_spelling_bad_dict(self):
     """Test spelling with a bad dict option."""
     po_check = PoCheck()
     po_check.set_spelling_options('str', 'xxx', None)
     self.assertEqual(len(po_check.extra_checkers), 0)