Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.test_genericpath.GenericTest Class Reference
Inheritance diagram for test.test_genericpath.GenericTest:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def test_no_argument
def test_commonprefix
def test_getsize
def test_time
def test_exists
def test_isdir
def test_isfile

Static Public Attributes

 pathmodule = genericpath
list common_attributes
list attributes = []

Detailed Description

Definition at line 19 of file test_genericpath.py.


Member Function Documentation

Definition at line 33 of file test_genericpath.py.

00033 
00034     def test_commonprefix(self):
00035         commonprefix = self.pathmodule.commonprefix
00036         self.assertEqual(
00037             commonprefix([]),
00038             ""
00039         )
00040         self.assertEqual(
00041             commonprefix(["/home/swenson/spam", "/home/swen/spam"]),
00042             "/home/swen"
00043         )
00044         self.assertEqual(
00045             commonprefix(["/home/swen/spam", "/home/swen/eggs"]),
00046             "/home/swen/"
00047         )
00048         self.assertEqual(
00049             commonprefix(["/home/swen/spam", "/home/swen/spam"]),
00050             "/home/swen/spam"
00051         )
00052         self.assertEqual(
00053             commonprefix(["home:swenson:spam", "home:swen:spam"]),
00054             "home:swen"
00055         )
00056         self.assertEqual(
00057             commonprefix([":home:swen:spam", ":home:swen:eggs"]),
00058             ":home:swen:"
00059         )
00060         self.assertEqual(
00061             commonprefix([":home:swen:spam", ":home:swen:spam"]),
00062             ":home:swen:spam"
00063         )
00064 
00065         self.assertEqual(
00066             commonprefix([b"/home/swenson/spam", b"/home/swen/spam"]),
00067             b"/home/swen"
00068         )
00069         self.assertEqual(
00070             commonprefix([b"/home/swen/spam", b"/home/swen/eggs"]),
00071             b"/home/swen/"
00072         )
00073         self.assertEqual(
00074             commonprefix([b"/home/swen/spam", b"/home/swen/spam"]),
00075             b"/home/swen/spam"
00076         )
00077         self.assertEqual(
00078             commonprefix([b"home:swenson:spam", b"home:swen:spam"]),
00079             b"home:swen"
00080         )
00081         self.assertEqual(
00082             commonprefix([b":home:swen:spam", b":home:swen:eggs"]),
00083             b":home:swen:"
00084         )
00085         self.assertEqual(
00086             commonprefix([b":home:swen:spam", b":home:swen:spam"]),
00087             b":home:swen:spam"
00088         )
00089 
00090         testlist = ['', 'abc', 'Xbcd', 'Xb', 'XY', 'abcd',
00091                     'aXc', 'abd', 'ab', 'aX', 'abcX']
00092         for s1 in testlist:
00093             for s2 in testlist:
00094                 p = commonprefix([s1, s2])
00095                 self.assertTrue(s1.startswith(p))
00096                 self.assertTrue(s2.startswith(p))
00097                 if s1 != s2:
00098                     n = len(p)
00099                     self.assertNotEqual(s1[n:n+1], s2[n:n+1])

Here is the call graph for this function:

Definition at line 133 of file test_genericpath.py.

00133 
00134     def test_exists(self):
00135         self.assertIs(self.pathmodule.exists(support.TESTFN), False)
00136         f = open(support.TESTFN, "wb")
00137         try:
00138             f.write(b"foo")
00139             f.close()
00140             self.assertIs(self.pathmodule.exists(support.TESTFN), True)
00141             if not self.pathmodule == genericpath:
00142                 self.assertIs(self.pathmodule.lexists(support.TESTFN),
00143                               True)
00144         finally:
00145             if not f.close():
00146                 f.close()
00147             support.unlink(support.TESTFN)

Here is the call graph for this function:

Definition at line 100 of file test_genericpath.py.

00100 
00101     def test_getsize(self):
00102         f = open(support.TESTFN, "wb")
00103         try:
00104             f.write(b"foo")
00105             f.close()
00106             self.assertEqual(self.pathmodule.getsize(support.TESTFN), 3)
00107         finally:
00108             if not f.closed:
00109                 f.close()
00110             support.unlink(support.TESTFN)

Here is the call graph for this function:

Definition at line 148 of file test_genericpath.py.

00148 
00149     def test_isdir(self):
00150         self.assertIs(self.pathmodule.isdir(support.TESTFN), False)
00151         f = open(support.TESTFN, "wb")
00152         try:
00153             f.write(b"foo")
00154             f.close()
00155             self.assertIs(self.pathmodule.isdir(support.TESTFN), False)
00156             os.remove(support.TESTFN)
00157             os.mkdir(support.TESTFN)
00158             self.assertIs(self.pathmodule.isdir(support.TESTFN), True)
00159             os.rmdir(support.TESTFN)
00160         finally:
00161             if not f.close():
00162                 f.close()
00163             support.unlink(support.TESTFN)
00164             safe_rmdir(support.TESTFN)

Here is the call graph for this function:

Definition at line 165 of file test_genericpath.py.

00165 
00166     def test_isfile(self):
00167         self.assertIs(self.pathmodule.isfile(support.TESTFN), False)
00168         f = open(support.TESTFN, "wb")
00169         try:
00170             f.write(b"foo")
00171             f.close()
00172             self.assertIs(self.pathmodule.isfile(support.TESTFN), True)
00173             os.remove(support.TESTFN)
00174             os.mkdir(support.TESTFN)
00175             self.assertIs(self.pathmodule.isfile(support.TESTFN), False)
00176             os.rmdir(support.TESTFN)
00177         finally:
00178             if not f.close():
00179                 f.close()
00180             support.unlink(support.TESTFN)
00181             safe_rmdir(support.TESTFN)
00182 
00183 
00184 # Following TestCase is not supposed to be run from test_genericpath.
00185 # It is inherited by other test modules (macpath, ntpath, posixpath).

Here is the call graph for this function:

Definition at line 26 of file test_genericpath.py.

00026 
00027     def test_no_argument(self):
00028         for attr in self.common_attributes + self.attributes:
00029             with self.assertRaises(TypeError):
00030                 getattr(self.pathmodule, attr)()
00031                 raise self.fail("{}.{}() did not raise a TypeError"
00032                                 .format(self.pathmodule.__name__, attr))

Here is the call graph for this function:

Definition at line 111 of file test_genericpath.py.

00111 
00112     def test_time(self):
00113         f = open(support.TESTFN, "wb")
00114         try:
00115             f.write(b"foo")
00116             f.close()
00117             f = open(support.TESTFN, "ab")
00118             f.write(b"bar")
00119             f.close()
00120             f = open(support.TESTFN, "rb")
00121             d = f.read()
00122             f.close()
00123             self.assertEqual(d, b"foobar")
00124 
00125             self.assertLessEqual(
00126                 self.pathmodule.getctime(support.TESTFN),
00127                 self.pathmodule.getmtime(support.TESTFN)
00128             )
00129         finally:
00130             if not f.closed:
00131                 f.close()
00132             support.unlink(support.TESTFN)

Here is the call graph for this function:


Member Data Documentation

Initial value:
['commonprefix', 'getsize', 'getatime', 'getctime',
                         'getmtime', 'exists', 'isdir', 'isfile']

Reimplemented in test.test_genericpath.CommonTest.

Definition at line 22 of file test_genericpath.py.


The documentation for this class was generated from the following file: