29
29
Actor ,
30
30
IterableList ,
31
31
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' ),
32
60
)
33
61
34
62
@@ -54,46 +82,45 @@ def setup(self):
54
82
"array" : [42 ],
55
83
}
56
84
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
+
57
92
@skipIf (not is_win , "Paths specifically for Windows." )
58
93
@ddt .data (
59
- (r'foo\bar' , 'foo/bar' ),
60
- (r'foo/bar' , 'foo/bar' ),
61
94
(r'./bar' , 'bar' ),
62
95
(r'.\bar' , 'bar' ),
63
96
(r'../bar' , '../bar' ),
64
97
(r'..\bar' , '../bar' ),
65
98
(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' ),
81
99
)
82
- def test_cygpath_ok (self , case ):
100
+ def test_cygpath_norm_ok (self , case ):
83
101
wpath , cpath = case
84
- self .assertEqual (cygpath (wpath ), cpath or wpath )
102
+ cwpath = cygpath (wpath )
103
+ self .assertEqual (cwpath , cpath or wpath , wpath )
85
104
86
105
@skipIf (not is_win , "Paths specifically for Windows." )
87
106
@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' ,
93
113
)
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 ):
95
121
wpath , cpath = case
96
- self .assertEqual (cygpath (wpath ), cpath or wpath .replace ('\\ ' , '/' ))
122
+ wcpath = decygpath (cpath )
123
+ self .assertEqual (wcpath , wpath .replace ('/' , '\\ ' ), cpath )
97
124
98
125
def test_it_should_dashify (self ):
99
126
assert_equal ('this-is-my-argument' , dashify ('this_is_my_argument' ))
0 commit comments