Esempio n. 1
0
 def test_father_and_f(self):
     inputs = ['a/b', '/a/b', '/a/b/', 'a/b/']
     outputs = ['a', '/a', '/a', 'a']
     subtests_ae(self, inputs, outputs, lambda x: Path(x).f)
     subtests_ae(self, inputs, outputs, lambda x: Path(x).father().s,
                 len(inputs))
     subtests(self, inputs, outputs,
              lambda xi, xo: self.assertIsInstance(Path(xi).father(), Path),
              len(inputs) * 2)
Esempio n. 2
0
 def test_div(self):
     with self.subTest(0):
         p = Path('/tmp')
         p = p / 'sub'
         self.assertEqual(p.s, '/tmp/sub')
     with self.subTest(1):
         p = Path('/tmp')
         p = p / 'sub/'
         self.assertEqual(p.s, '/tmp/sub')
Esempio n. 3
0
 def test_name_and_n(self):
     inputs = ['/', 'a', '/a/b', '/a/b/']
     outputs = ['', 'a', 'b', 'b']
     subtests_ae(self, inputs, outputs, lambda x: Path(x).n)
     subtests_ae(self, inputs, outputs, lambda x: Path(x).name().s,
                 len(inputs))
     subtests(self, inputs, outputs,
              lambda xi, xo: self.assertIsInstance(Path(xi).name(), Path),
              len(inputs) * 2)
Esempio n. 4
0
 def test_relative(self):
     inputs = ['/', 'tmp', '/tmp', '/tmp/']
     outputs = ['', 'tmp', 'tmp', 'tmp']
     subtests_ae(self, inputs, outputs, lambda x: Path(x).r)
     subtests_ae(self, inputs, outputs, lambda x: Path(x).relative().s,
                 len(inputs))
     subtests(self, inputs, outputs,
              lambda xi, xo: self.assertIsInstance(Path(xi).relative(),
                                                   Path),
              len(inputs) * 2)
Esempio n. 5
0
 def test_absolute_and_a(self):
     inputs = ['/', 'tmp', '/tmp']
     outputs = ['/', '/tmp', '/tmp']
     subtests_ae(self, inputs, outputs, lambda x: Path(x).a)
     subtests_ae(self, inputs, outputs, lambda x: Path(x).absolute().s,
                 len(inputs))
     subtests(self, inputs, outputs,
              lambda xi, xo: self.assertIsInstance(Path(xi).absolute(),
                                                   Path),
              len(inputs) * 2)
Esempio n. 6
0
 def test_parts(self):
     with self.subTest(0):
         p = Path('/tmp/base')
         self.assertEqual(p.parts(), ('/', 'tmp', 'base'))
     with self.subTest(1):
         p = Path('a/b')
         self.assertEqual(p.parts(), ('a', 'b'))
Esempio n. 7
0
 def test_empty_protocol(self):
     self.assertEqual(Path('a', '').s, 'a')
Esempio n. 8
0
 def test_join_dot(self):
     self.assertEqual((Path('.') / 'a').s, 'a')
Esempio n. 9
0
 def test_dot(self):
     self.assertEqual(Path('.').s, '')
Esempio n. 10
0
 def test_eq(self):
     ips = ['a', 'a/b', '/a/b', './a', '/a/b/c/..']
     ops = ['a', 'a/b', '/a/b', './a', '/a/b']
     subtests(self, ips, ops,
              lambda xi, xo: self.assertTrue(Path(xi) == Path(xo)))
Esempio n. 11
0
 def test_s(self):
     inputs = ['/', '/tmp', '%2Ftmp', '%252Ftmp', './tmp', '/tmp/a/..']
     outputs = ['/', '/tmp', '/tmp', '/tmp', 'tmp', '/tmp']
     subtests_ae(self, inputs, outputs, lambda x: Path(x).s)
     subtests_ae(self, inputs, outputs, lambda x: Path(x).raw, len(inputs))