Anonymous committed c255872

Add tests for Path('.').ext

Comments (0)

Files changed (2)

         if len(parts) == (1 if (self._drv or self._root) else 0):
             return ''
         basename = parts[-1]
+        if basename == '.':
+            return ''
         i = basename.find('.')
-        return basename[i:] if i != -1 else ''
+        if i == -1:
+            return ''
+        return basename[i:]
     def relative(self):
         """Return a new path without any drive and root.
             return self
         # FIXME this must defer to the specific flavour (and, under Windows,
         # use nt._getfullpathname())
-        obj = self._from_parts((os.getcwd(),) + self._parts, init=False)
+        obj = self._from_parts([os.getcwd()] + self._parts, init=False)
         obj._init(template=self, parent_fd=self._parent_fd, fd=self._cached_fd)
         return obj


     def test_ext_common(self):
         P = self.cls
         self.assertEqual(P('').ext, '')
+        self.assertEqual(P('.').ext, '')
         self.assertEqual(P('/').ext, '')
         self.assertEqual(P('a/b').ext, '')
         self.assertEqual(P('/a/b').ext, '')
+        self.assertEqual(P('/a/b/.').ext, '')
         self.assertEqual(P('a/').ext, '.py')
         self.assertEqual(P('/a/').ext, '.py')
         self.assertEqual(P('a/b.tar.gz').ext, '.tar.gz')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.