Skip to content

Commit 2fbdcff

Browse files
committed
Handle windows path separators in tests
1 parent 0a56fd3 commit 2fbdcff

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

testing/test_git.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from setuptools_scm import git
44
import pytest
55
from datetime import date
6+
from os.path import join as opj
67

78

89
@pytest.fixture
@@ -124,7 +125,7 @@ def test_git_archive_export_ignore(wd):
124125
wd('git add test1.txt test2.txt')
125126
wd.commit()
126127
with wd.cwd.as_cwd():
127-
assert integration.find_files('.') == ['./test1.txt']
128+
assert integration.find_files('.') == [opj('.', 'test1.txt')]
128129

129130

130131
@pytest.mark.issue(228)
@@ -134,7 +135,7 @@ def test_git_archive_subdirectory(wd):
134135
wd('git add foobar')
135136
wd.commit()
136137
with wd.cwd.as_cwd():
137-
assert integration.find_files('.') == ['./foobar/test1.txt']
138+
assert integration.find_files('.') == [opj('.', 'foobar', 'test1.txt')]
138139

139140

140141
def test_git_feature_branch_increments_major(wd):

testing/test_git_file_finder.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,65 +23,72 @@ def inwd(wd):
2323
yield wd
2424

2525

26+
def _sep(paths):
27+
return {
28+
path.replace('/', os.path.sep)
29+
for path in paths
30+
}
31+
32+
2633
def test_basic(inwd):
27-
assert set(find_files()) == {
34+
assert set(find_files()) == _sep({
2835
'file1',
2936
'adir/filea',
3037
'bdir/fileb',
31-
}
32-
assert set(find_files('.')) == {
38+
})
39+
assert set(find_files('.')) == _sep({
3340
'./file1',
3441
'./adir/filea',
3542
'./bdir/fileb',
36-
}
37-
assert set(find_files('adir')) == {
43+
})
44+
assert set(find_files('adir')) == _sep({
3845
'adir/filea',
39-
}
46+
})
4047

4148

4249
def test_case(inwd):
4350
(inwd.cwd / 'CamelFile').ensure(file=True)
4451
(inwd.cwd / 'file2').ensure(file=True)
4552
inwd.add_and_commit()
46-
assert set(find_files()) == {
53+
assert set(find_files()) == _sep({
4754
'CamelFile',
4855
'file2',
4956
'file1',
5057
'adir/filea',
5158
'bdir/fileb',
52-
}
59+
})
5360

5461

5562
@pytest.mark.skipif(sys.platform == 'win32',
5663
reason="symlinks to dir not supported")
5764
def test_symlink_dir(inwd):
5865
(inwd.cwd / 'adir' / 'bdirlink').mksymlinkto('../bdir')
5966
inwd.add_and_commit()
60-
assert set(find_files('adir')) == {
67+
assert set(find_files('adir')) == _sep({
6168
'adir/filea',
6269
'adir/bdirlink/fileb',
63-
}
70+
})
6471

6572

6673
@pytest.mark.skipif(sys.platform == 'win32',
6774
reason="symlinks to files not supported on windows")
6875
def test_symlink_file(inwd):
6976
(inwd.cwd / 'adir' / 'file1link').mksymlinkto('../file1')
7077
inwd.add_and_commit()
71-
assert set(find_files('adir')) == {
78+
assert set(find_files('adir')) == _sep({
7279
'adir/filea',
7380
'adir/file1link',
74-
}
81+
})
7582

7683

7784
@pytest.mark.skipif(sys.platform == 'win32',
7885
reason="symlinks to dir not supported")
7986
def test_symlink_loop(inwd):
8087
(inwd.cwd / 'adir' / 'loop').mksymlinkto('../adir')
8188
inwd.add_and_commit()
82-
assert set(find_files('adir')) == {
89+
assert set(find_files('adir')) == _sep({
8390
'adir/filea',
84-
}
91+
})
8592

8693

8794
@pytest.mark.skipif(sys.platform == 'win32',
@@ -90,37 +97,37 @@ def test_symlink_dir_out_of_git(inwd):
9097
(inwd.cwd / 'adir' / 'outsidedirlink').\
9198
mksymlinkto(os.path.join(__file__, '..'))
9299
inwd.add_and_commit()
93-
assert set(find_files('adir')) == {
100+
assert set(find_files('adir')) == _sep({
94101
'adir/filea',
95-
}
102+
})
96103

97104

98105
@pytest.mark.skipif(sys.platform == 'win32',
99106
reason="symlinks to files not supported on windows")
100107
def test_symlink_file_out_of_git(inwd):
101108
(inwd.cwd / 'adir' / 'outsidefilelink').mksymlinkto(__file__)
102109
inwd.add_and_commit()
103-
assert set(find_files('adir')) == {
110+
assert set(find_files('adir')) == _sep({
104111
'adir/filea',
105-
}
112+
})
106113

107114

108115
def test_empty_root(inwd):
109116
subdir = inwd.cwd / 'cdir' / 'subdir'
110117
subdir.ensure(dir=True)
111118
(subdir / 'filec').ensure(file=True)
112119
inwd.add_and_commit()
113-
assert set(find_files('cdir')) == {
120+
assert set(find_files('cdir')) == _sep({
114121
'cdir/subdir/filec',
115-
}
122+
})
116123

117124

118125
def test_empty_subdir(inwd):
119126
subdir = inwd.cwd / 'adir' / 'emptysubdir' / 'subdir'
120127
subdir.ensure(dir=True)
121128
(subdir / 'xfile').ensure(file=True)
122129
inwd.add_and_commit()
123-
assert set(find_files('adir')) == {
130+
assert set(find_files('adir')) == _sep({
124131
'adir/filea',
125132
'adir/emptysubdir/subdir/xfile',
126-
}
133+
})

0 commit comments

Comments
 (0)