Ejemplo n.º 1
0
 def test_clean_filename_whitespace_handling(self):
     # Leading and trailing whitespace stripped.
     self.assertEqual(clean_filename(" abc "), "abc")
     self.assertEqual(clean_filename(" \t\tabc    \n"), "abc")
     # Internal whitespace turned into hyphens.
     self.assertEqual(clean_filename("well name"), "well-name")
     self.assertEqual(clean_filename("well \n name"), "well-name")
     self.assertEqual(clean_filename("well - name"), "well-name")
Ejemplo n.º 2
0
 def test_clean_filename_all_chars(self):
     test_strings = [
         "".join(chr(n) for n in range(10000)),
         "".join(chr(n) for n in range(10000)) * 2,
         "".join(chr(n) for n in reversed(range(10000))),
     ]
     for test_string in test_strings:
         safe_string = clean_filename(test_string)
         self.check_output(safe_string)
Ejemplo n.º 3
0
 def test_clean_filename_accented_chars(self):
     test_strings = [
         "\xe4b\xe7d\xe8f",
         "a\u0308bc\u0327de\u0300f",
     ]
     for test_string in test_strings:
         safe_string = clean_filename(test_string)
         self.check_output(safe_string)
         self.assertEqual(safe_string, "abcdef")
Ejemplo n.º 4
0
 def test_clean_filename_default(self):
     test_strings = [
         "!!!",
         "",
         " ",
         "\t/\n",
         "^!+",
     ]
     for test_string in test_strings:
         safe_string = clean_filename(test_string, "default-output")
         self.check_output(safe_string)
         self.assertEqual(safe_string, "default-output")
Ejemplo n.º 5
0
    def get_default_project_location(self, application):
        """
        Return the default location for a new project.

        """

        path = self.get_default_path(application)
        name = clean_filename(self.get_default_name())
        location = os.path.join(path, name)
        location = self._make_location_unique(location)

        return location
Ejemplo n.º 6
0
    def get_default_project_location(self, application):
        """
        Return the default location for a new project.

        """

        path = self.get_default_path(application)
        name = clean_filename(self.get_default_name())
        location = os.path.join(path, name)
        location = self._make_location_unique(location)

        return location
Ejemplo n.º 7
0
 def test_clean_filename_conversion_to_lowercase(self):
     test_string = "ABCdefGHI123"
     safe_string = clean_filename(test_string)
     self.assertEqual(safe_string, test_string.lower())
     self.check_output(safe_string)