[Python-checkins] python/dist/src/Lib/test test_macpath.py,NONE,1.1 test_ntpath.py,1.16,1.17 test_posixpath.py,1.4,1.5

loewis@users.sourceforge.net loewis@users.sourceforge.net
2002年12月12日 12:30:22 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv24335/Lib/test
Modified Files:
	test_ntpath.py test_posixpath.py 
Added Files:
	test_macpath.py 
Log Message:
Patch #536661: Improve performance of splitext. Add test_macpath.
--- NEW FILE: test_macpath.py ---
import macpath
from test import test_support
import unittest
class MacPathTestCase(unittest.TestCase):
 def test_abspath(self):
 self.assert_(macpath.abspath("xx:yy") == "xx:yy")
 def test_isabs(self):
 isabs = macpath.isabs
 self.assert_(isabs("xx:yy"))
 self.assert_(isabs("xx:yy:"))
 self.assert_(isabs("xx:"))
 self.failIf(isabs("foo"))
 self.failIf(isabs(":foo"))
 self.failIf(isabs(":foo:bar"))
 self.failIf(isabs(":foo:bar:"))
 def test_commonprefix(self):
 commonprefix = macpath.commonprefix
 self.assert_(commonprefix(["home:swenson:spam", "home:swen:spam"])
 == "home:swen")
 self.assert_(commonprefix([":home:swen:spam", ":home:swen:eggs"])
 == ":home:swen:")
 self.assert_(commonprefix([":home:swen:spam", ":home:swen:spam"])
 == ":home:swen:spam")
 def test_split(self):
 split = macpath.split
 self.assertEquals(split("foo:bar"),
 ('foo:', 'bar'))
 self.assertEquals(split("conky:mountpoint:foo:bar"),
 ('conky:mountpoint:foo', 'bar'))
 self.assertEquals(split(":"), ('', ''))
 self.assertEquals(split(":conky:mountpoint:"),
 (':conky:mountpoint', ''))
 def test_splitdrive(self):
 splitdrive = macpath.splitdrive
 self.assertEquals(splitdrive("foo:bar"), ('', 'foo:bar'))
 self.assertEquals(splitdrive(":foo:bar"), ('', ':foo:bar'))
 def test_splitext(self):
 splitext = macpath.splitext
 self.assertEquals(splitext(":foo.ext"), (':foo', '.ext'))
 self.assertEquals(splitext("foo:foo.ext"), ('foo:foo', '.ext'))
 self.assertEquals(splitext(".ext"), ('', '.ext'))
 self.assertEquals(splitext("foo.ext:foo"), ('foo.ext:foo', ''))
 self.assertEquals(splitext(":foo.ext:"), (':foo.ext:', ''))
 self.assertEquals(splitext(""), ('', ''))
 self.assertEquals(splitext("foo.bar.ext"), ('foo.bar', '.ext'))
def test_main():
 test_support.run_unittest(MacPathTestCase)
if __name__ == "__main__":
 test_main()
Index: test_ntpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ntpath.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** test_ntpath.py	23 Jul 2002 19:03:58 -0000	1.16
--- test_ntpath.py	12 Dec 2002 20:30:20 -0000	1.17
***************
*** 16,19 ****
--- 16,29 ----
 print ""
 errors = errors + 1
+ 
+ tester('ntpath.splitext("foo.ext")', ('foo', '.ext'))
+ tester('ntpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
+ tester('ntpath.splitext(".ext")', ('', '.ext'))
+ tester('ntpath.splitext("\\foo.ext\\foo")', ('\\foo.ext\\foo', ''))
+ tester('ntpath.splitext("foo.ext\\")', ('foo.ext\\', ''))
+ tester('ntpath.splitext("")', ('', ''))
+ tester('ntpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
+ tester('ntpath.splitext("xx/foo.bar.ext")', ('xx/foo.bar', '.ext'))
+ tester('ntpath.splitext("xx\\foo.bar.ext")', ('xx\\foo.bar', '.ext'))
 
 tester('ntpath.splitdrive("c:\\foo\\bar")',
Index: test_posixpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_posixpath.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_posixpath.py	9 Feb 2001 11:52:01 -0000	1.4
--- test_posixpath.py	12 Dec 2002 20:30:20 -0000	1.5
***************
*** 22,25 ****
--- 22,30 ----
 tester('posixpath.splitext("foo.ext")', ('foo', '.ext'))
 tester('posixpath.splitext("/foo/foo.ext")', ('/foo/foo', '.ext'))
+ tester('posixpath.splitext(".ext")', ('', '.ext'))
+ tester('posixpath.splitext("/foo.ext/foo")', ('/foo.ext/foo', ''))
+ tester('posixpath.splitext("foo.ext/")', ('foo.ext/', ''))
+ tester('posixpath.splitext("")', ('', ''))
+ tester('posixpath.splitext("foo.bar.ext")', ('foo.bar', '.ext'))
 
 tester('posixpath.isabs("/")', 1)

AltStyle によって変換されたページ (->オリジナル) /