2929 Actor ,
3030 IterableList ,
3131 cygpath ,
32+ decygpath
33+ )
34+
35+
36+ _norm_cygpath_pairs = (
37+ (r'foo\bar' , 'foo/bar' ),
38+ (r'foo/bar' , 'foo/bar' ),
39+
40+ (r'C:\Users' , '/cygdrive/c/Users' ),
41+ (r'C:\d/e' , '/cygdrive/c/d/e' ),
42+
43+ ('C:\\ ' , '/cygdrive/c/' ),
44+
45+ (r'\\server\C$\Users' , '//server/C$/Users' ),
46+ (r'\\server\C$' , '//server/C$' ),
47+ ('\\ \\ server\\ c$\\ ' , '//server/c$/' ),
48+ (r'\\server\BAR/' , '//server/BAR/' ),
49+
50+ (r'D:/Apps' , '/cygdrive/d/Apps' ),
51+ (r'D:/Apps\fOO' , '/cygdrive/d/Apps/fOO' ),
52+ (r'D:\Apps/123' , '/cygdrive/d/Apps/123' ),
53+ )
54+
55+ _unc_cygpath_pairs = (
56+ (r'\\?\a:\com' , '/cygdrive/a/com' ),
57+ (r'\\?\a:/com' , '/cygdrive/a/com' ),
58+
59+ (r'\\?\UNC\server\D$\Apps' , '//server/D$/Apps' ),
3260)
3361
3462
@@ -54,46 +82,45 @@ def setup(self):
5482 "array" : [42 ],
5583 }
5684
85+ @skipIf (not is_win , "Paths specifically for Windows." )
86+ @ddt .idata (_norm_cygpath_pairs + _unc_cygpath_pairs )
87+ def test_cygpath_ok (self , case ):
88+ wpath , cpath = case
89+ cwpath = cygpath (wpath )
90+ self .assertEqual (cwpath , cpath , wpath )
91+
5792 @skipIf (not is_win , "Paths specifically for Windows." )
5893 @ddt .data (
59- (r'foo\bar' , 'foo/bar' ),
60- (r'foo/bar' , 'foo/bar' ),
6194 (r'./bar' , 'bar' ),
6295 (r'.\bar' , 'bar' ),
6396 (r'../bar' , '../bar' ),
6497 (r'..\bar' , '../bar' ),
6598 (r'../bar/.\foo/../chu' , '../bar/chu' ),
66-
67- (r'C:\Users' , '/cygdrive/c/Users' ),
68- (r'C:\d/e' , '/cygdrive/c/d/e' ),
69-
70- (r'\\?\a:\com' , '/cygdrive/a/com' ),
71- (r'\\?\a:/com' , '/cygdrive/a/com' ),
72-
73- (r'\\server\C$\Users' , '//server/C$/Users' ),
74- (r'\\server\C$' , '//server/C$' ),
75- (r'\\server\BAR/' , '//server/BAR/' ),
76- (r'\\?\UNC\server\D$\Apps' , '//server/D$/Apps' ),
77-
78- (r'D:/Apps' , '/cygdrive/d/Apps' ),
79- (r'D:/Apps\fOO' , '/cygdrive/d/Apps/fOO' ),
80- (r'D:\Apps/123' , '/cygdrive/d/Apps/123' ),
8199 )
82- def test_cygpath_ok (self , case ):
100+ def test_cygpath_norm_ok (self , case ):
83101 wpath , cpath = case
84- self .assertEqual (cygpath (wpath ), cpath or wpath )
102+ cwpath = cygpath (wpath )
103+ self .assertEqual (cwpath , cpath or wpath , wpath )
85104
86105 @skipIf (not is_win , "Paths specifically for Windows." )
87106 @ddt .data (
88- (r'C:Relative' , None ),
89- (r'D:Apps\123' , None ),
90- (r'D:Apps/123' , None ),
91- (r'\\?\a:rel' , None ),
92- (r'\\share\a:rel' , None ),
107+ r'C:' ,
108+ r'C:Relative' ,
109+ r'D:Apps\123' ,
110+ r'D:Apps/123' ,
111+ r'\\?\a:rel' ,
112+ r'\\share\a:rel' ,
93113 )
94- def test_cygpath_invalids (self , case ):
114+ def test_cygpath_invalids (self , wpath ):
115+ cwpath = cygpath (wpath )
116+ self .assertEqual (cwpath , wpath .replace ('\\ ' , '/' ), wpath )
117+
118+ @skipIf (not is_win , "Paths specifically for Windows." )
119+ @ddt .idata (_norm_cygpath_pairs )
120+ def test_decygpath (self , case ):
95121 wpath , cpath = case
96- self .assertEqual (cygpath (wpath ), cpath or wpath .replace ('\\ ' , '/' ))
122+ wcpath = decygpath (cpath )
123+ self .assertEqual (wcpath , wpath .replace ('/' , '\\ ' ), cpath )
97124
98125 def test_it_should_dashify (self ):
99126 assert_equal ('this-is-my-argument' , dashify ('this_is_my_argument' ))
0 commit comments