MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_join

Method test_join

Lib/test/test_pathlib/test_join_windows.py:13–46  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

11
12class JoinTestBase:
13 def test_join(self):
14 P = self.cls
15 p = P('C:/a/b')
16 pp = p.joinpath('x/y')
17 self.assertEqual(pp, P(r'C:/a/b\x/y'))
18 pp = p.joinpath('/x/y')
19 self.assertEqual(pp, P('C:/x/y'))
20 # Joining with a different drive => the first path is ignored, even
21 # if the second path is relative.
22 pp = p.joinpath('D:x/y')
23 self.assertEqual(pp, P('D:x/y'))
24 pp = p.joinpath('D:/x/y')
25 self.assertEqual(pp, P('D:/x/y'))
26 pp = p.joinpath('//host/share/x/y')
27 self.assertEqual(pp, P('//host/share/x/y'))
28 # Joining with the same drive => the first path is appended to if
29 # the second path is relative.
30 pp = p.joinpath('c:x/y')
31 self.assertEqual(pp, P(r'c:/a/b\x/y'))
32 pp = p.joinpath('c:/x/y')
33 self.assertEqual(pp, P('c:/x/y'))
34 # Joining with files with NTFS data streams => the filename should
35 # not be parsed as a drive letter
36 pp = p.joinpath('./d:s')
37 self.assertEqual(pp, P(r'C:/a/b\./d:s'))
38 pp = p.joinpath('./dd:s')
39 self.assertEqual(pp, P(r'C:/a/b\./dd:s'))
40 pp = p.joinpath('E:d:s')
41 self.assertEqual(pp, P('E:d:s'))
42 # Joining onto a UNC path with no root
43 pp = P('//server').joinpath('share')
44 self.assertEqual(pp, P(r'//server\share'))
45 pp = P('//./BootPartition').joinpath('Windows')
46 self.assertEqual(pp, P(r'//./BootPartition\Windows'))
47
48 def test_div(self):
49 # Basically the same as joinpath().

Callers

nothing calls this directly

Calls 3

PClass · 0.70
joinpathMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected