Esempio n. 1
0
    def test_text_with_non_ascii_character(self):
        """has_invalid_characters: detects non-ASCII character in text
        """
        self.assertTrue(
            has_invalid_characters(text=u"""This text contains:
a non-ASCII character here\x80
"""))
Esempio n. 2
0
    def test_text_with_non_printing_ascii_character(self):
        """has_invalid_characters: detects non-printing ASCII character in text
        """
        self.assertTrue(
            has_invalid_characters(text=u"""This file contains:
a non-printing ASCII ctrl-S character here\x13
"""))
Esempio n. 3
0
    def test_file_with_non_ascii_character(self):
        """has_invalid_characters: detects non-ASCII character in file
        """
        non_ascii_file = os.path.join(self.wd, "test.nonascii")
        with codecs.open(non_ascii_file, 'wb', encoding='utf-8') as fp:
            fp.write(u"""This file contains:
a non-ASCII character here\x80
""")
        self.assertTrue(has_invalid_characters(non_ascii_file))
    def test_file_with_non_ascii_character(self):
        """has_invalid_characters: detects non-ASCII character in file
        """
        non_ascii_file = os.path.join(self.wd,"test.nonascii")
        with codecs.open(non_ascii_file,'wb',encoding='utf-8') as fp:
            fp.write(u"""This file contains:
a non-ASCII character here\x80
""")
        self.assertTrue(has_invalid_characters(non_ascii_file))
Esempio n. 5
0
    def test_file_with_non_printing_ascii_character(self):
        """has_invalid_characters: detects non-printing ASCII character in file
        """
        non_printing_ascii_file = os.path.join(self.wd,
                                               "test.nonprintingascii")
        with open(non_printing_ascii_file, 'wt') as fp:
            fp.write(u"""This file contains:
a non-printing ASCII ctrl-S character here\x13
""")
        self.assertTrue(has_invalid_characters(non_printing_ascii_file))
    def test_file_with_non_printing_ascii_character(self):
        """has_invalid_characters: detects non-printing ASCII character in file
        """
        non_printing_ascii_file = os.path.join(self.wd,
                                               "test.nonprintingascii")
        with open(non_printing_ascii_file,'wb') as fp:
            fp.write(u"""This file contains:
a non-printing ASCII ctrl-S character here\x13
""")
        self.assertTrue(has_invalid_characters(non_printing_ascii_file))
    def test_text_with_valid_characters(self):
        """has_invalid_characters: works for valid text
        """
        self.assertFalse(has_invalid_characters(text=u"""This file contains valid characters:
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
- abcdefghijklmnopqrstuvwxyz
- 01234567890
- !"$%^&*()_-+=\|/:;'@#~`?
- {}[]
- \t\n
"""))
Esempio n. 8
0
    def test_file_with_valid_characters(self):
        """has_invalid_characters: works for valid file
        """
        valid_file = os.path.join(self.wd, "test.valid")
        with open(valid_file, 'wt') as fp:
            fp.write(u"""This file contains valid characters:
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
- abcdefghijklmnopqrstuvwxyz
- 01234567890
- !"$%^&*()_-+=\\|/:;'@#~`?
- {}[]
- \t\n
""")
        self.assertFalse(has_invalid_characters(valid_file))
    def test_file_with_valid_characters(self):
        """has_invalid_characters: works for valid file
        """
        valid_file = os.path.join(self.wd,"test.valid")
        with open(valid_file,'wb') as fp:
            fp.write(u"""This file contains valid characters:
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
- abcdefghijklmnopqrstuvwxyz
- 01234567890
- !"$%^&*()_-+=\|/:;'@#~`?
- {}[]
- \t\n
""")
        self.assertFalse(has_invalid_characters(valid_file))
    def test_text_with_non_ascii_character(self):
        """has_invalid_characters: detects non-ASCII character in text
        """
        self.assertTrue(has_invalid_characters(text=u"""This text contains:
a non-ASCII character here\x80
"""))
    def test_text_with_non_printing_ascii_character(self):
        """has_invalid_characters: detects non-printing ASCII character in text
        """
        self.assertTrue(has_invalid_characters(text=u"""This file contains:
a non-printing ASCII ctrl-S character here\x13
"""))