Ejemplo n.º 1
0
 def test_iter_to_list(I):
     'Test UPath as an iter by converting to list.'
     p = uripath.UPath('/usr/local/lib/python2.7/site-packages/jazzy')
     # convert UPath to list
     a = list(p)
     I.assertTrue(len(a) == len(p))
     I.assertTrue(isinstance(a[0], uripath.RootUPath))
     I.assertTrue(all(uripath.isUPath(i) for i in a))
     I.assertTrue(all(a[i] == p[i] for i in range(7)))
     I.assertTrue(all(i == j for i, j in zip(a, p)))
Ejemplo n.º 2
0
 def test_iter_append(I):
     'Test UPath as an iter using list append.'
     p = uripath.UPath('/usr/local/lib/python2.7/site-packages/jazzy')
     # old-fashioned append
     a = []
     for part in p:
         a.append(part)
     I.assertTrue(len(a) == len(p))
     I.assertTrue(isinstance(a[0], uripath.RootUPath))
     I.assertTrue(all(uripath.isUPath(i) for i in a))
     I.assertTrue(all(a[i] == p[i] for i in range(7)))
     I.assertTrue(all(i == j for i, j in zip(a, p)))
Ejemplo n.º 3
0
 def test_ctor(I):
     'Test RootUPath()'
     p = uripath.RootUPath()
     I.assertTrue(uripath.isUPath(p))
     I.assertTrue(str(p) == '/')
Ejemplo n.º 4
0
 def assertUPath(I, sut, value, length=None):
     'Assert that SUT is a UPath with the given value and length.'
     I.assertTrue(uripath.isUPath(sut))
     I.assertTrue(sut == value, '[{}] v [{}]'.format(sut, value))
     if length is not None:
         I.assertTrue(len(sut) == length)
Ejemplo n.º 5
0
 def assertIsRoot(I, sut):
     'Assert that SUT is the root path "/" .'
     I.assertTrue(isinstance(sut, uripath.RootUPath))
     I.assertTrue(uripath.isUPath(sut))
     I.assertTrue(str(sut) == '/')
     I.assertTrue(sut == '/')