Skip to content

Commit 6dadad5

Browse files
committed
Patching tests for Windows.
Windows does console colors through the win32 API instead of ANSI characters (changed in Windows 10 a few months ago but that's very new). Skipping log color tests on Windows. Having tests use os.path.join() instead of hard coding unix path separators.
1 parent 2b33dcd commit 6dadad5

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

tests/test__main__/test_arguments.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test mixing sources of arguments/settings."""
22

3+
from os.path import join
4+
35
import pytest
46
from click.testing import CliRunner
57

@@ -31,7 +33,7 @@ def test_overflow(local_empty, push, source_cli, source_conf):
3133
if push:
3234
args = ['push', 'docs', 'gh-pages', '.']
3335
else:
34-
args = ['build', 'docs', 'docs/_build/html']
36+
args = ['build', 'docs', join('docs', '_build', 'html')]
3537

3638
# Setup source(s).
3739
if source_cli:
@@ -66,9 +68,9 @@ def test_args(push):
6668
assert dest_branch == 'gh-pages'
6769
assert rel_dest == '.'
6870
else:
69-
result = CliRunner().invoke(cli, ['build', 'docs', 'docs/_build/html'])
71+
result = CliRunner().invoke(cli, ['build', 'docs', join('docs', '_build', 'html')])
7072
rel_source, destination = result.exception.args[1:]
71-
assert destination == 'docs/_build/html'
73+
assert destination == join('docs', '_build', 'html')
7274
assert rel_source == ('docs',)
7375

7476
# Multiple rel_source.
@@ -98,7 +100,7 @@ def test_global_options(monkeypatch, tmpdir, caplog, local_empty, run, push):
98100
if push:
99101
args = ['push', 'docs', 'gh-pages', '.']
100102
else:
101-
args = ['build', 'docs', 'docs/_build/html']
103+
args = ['build', 'docs', join('docs', '_build', 'html')]
102104

103105
# Defaults.
104106
result = CliRunner().invoke(cli, args)
@@ -140,7 +142,7 @@ def test_global_options(monkeypatch, tmpdir, caplog, local_empty, run, push):
140142
config = result.exception.args[0]
141143
assert config.chdir == str(local_empty)
142144
assert config.git_root == str(local_empty)
143-
assert config.local_conf == 'docs/conf.py'
145+
assert config.local_conf == join('docs', 'conf.py')
144146
assert config.no_colors is True
145147
assert config.no_local_conf is False
146148
assert config.verbose == 2
@@ -166,17 +168,17 @@ def test_global_options_local_conf(caplog, local_empty, mode, no_local_conf, pus
166168
if push:
167169
args += ['push', 'docs', 'gh-pages', '.']
168170
else:
169-
args += ['build', 'docs', 'docs/_build/html']
171+
args += ['build', 'docs', join('docs', '_build', 'html')]
170172

171173
# Run.
172174
if mode == 'bad filename':
173175
local_empty.ensure('docs', 'config.py')
174-
args = ['-l', 'docs/config.py'] + args
176+
args = ['-l', join('docs', 'config.py')] + args
175177
elif mode == 'rel_source':
176178
local_empty.ensure('docs', 'conf.py')
177179
else:
178180
local_empty.ensure('other', 'conf.py')
179-
args = ['-l', 'other/conf.py'] + args
181+
args = ['-l', join('other', 'conf.py')] + args
180182
result = CliRunner().invoke(cli, args)
181183
config = result.exception.args[0]
182184
records = [(r.levelname, r.message) for r in caplog.records]
@@ -188,12 +190,12 @@ def test_global_options_local_conf(caplog, local_empty, mode, no_local_conf, pus
188190
return
189191
if mode == 'bad filename':
190192
assert config == 1 # SystemExit.
191-
assert records[-2] == ('ERROR', 'Path "docs/config.py" must end with conf.py.')
193+
assert records[-2] == ('ERROR', 'Path "{}" must end with conf.py.'.format(join('docs', 'config.py')))
192194
elif mode == 'rel_source':
193-
assert config.local_conf == 'docs/conf.py'
195+
assert config.local_conf == join('docs', 'conf.py')
194196
assert config.no_local_conf is False
195197
else:
196-
assert config.local_conf == 'other/conf.py'
198+
assert config.local_conf == join('other', 'conf.py')
197199
assert config.no_local_conf is False
198200

199201

@@ -211,7 +213,7 @@ def test_sub_command_options(local_empty, push, source_cli, source_conf):
211213
if push:
212214
args = ['push', 'docs', 'gh-pages', '.']
213215
else:
214-
args = ['build', 'docs', 'docs/_build/html']
216+
args = ['build', 'docs', join('docs', '_build', 'html')]
215217

216218
# Setup source(s).
217219
if source_cli:
@@ -303,7 +305,7 @@ def test_sub_command_options_other(push):
303305
if push:
304306
args = ['push', 'docs', 'gh-pages', '.']
305307
else:
306-
args = ['build', 'docs', 'docs/_build/html']
308+
args = ['build', 'docs', join('docs', '_build', 'html')]
307309

308310
# Defined.
309311
args += ['-p', 'tags', '-s', 'semver', '-s', 'time']

tests/test_setup_logging.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import pytest
1010

11+
from sphinxcontrib.versioning.git import IS_WINDOWS
1112
from sphinxcontrib.versioning.setup_logging import ColorFormatter, setup_logging
1213

1314

@@ -83,6 +84,7 @@ def test_arrow(tmpdir, run, verbose):
8384
assert '\nWithout arrow.' in output
8485

8586

87+
@pytest.mark.skipif(str(IS_WINDOWS))
8688
def test_colors(tmpdir, run):
8789
"""Test colors.
8890

0 commit comments

Comments
 (0)