Skip to content

Commit c4aab3b

Browse files
committed
tests: use os.devnull instead of '/dev/null' for Windows CI
1 parent 5655752 commit c4aab3b

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

tests/test_cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_cli_run_with_args_fd(capfd):
8585
def test_cli_run_subprocess_exception(runner, mocker):
8686
result = runner.invoke(cli.run, [os.devnull])
8787
out = result.output.splitlines()
88-
assert out[-1].startswith("Error: Failed to run ['/dev/null', '--cmd',")
88+
assert out[-1].startswith("Error: Failed to run ['%s', '--cmd'," % os.devnull)
8989
assert '[Errno 13] Permission denied' in out[-1]
9090
assert result.exit_code == 1
9191

@@ -136,7 +136,7 @@ def test_cli_run_args(runner, mocker, devnull, tmpdir):
136136
assert m.call_args[0] == (['printf', '--', '--headless'],)
137137
assert result.output.splitlines() == [
138138
'Running cmd: printf -- --headless (in %s)' % os.getcwd(),
139-
'Parsing profile file /dev/null.',
139+
'Parsing profile file %s.' % os.devnull,
140140
'Not writing coverage file: no data to report!',
141141
'Error: Command exited non-zero: 3.']
142142

@@ -329,7 +329,7 @@ def test_cli_call_verbosity_fd(capfd):
329329
out, err = capfd.readouterr()
330330
assert out == ''
331331
assert err.splitlines() == [
332-
'Parsing file: /dev/null',
332+
'Parsing file: %s' % os.devnull,
333333
'source_files: []',
334334
'Not writing coverage file: no data to report!',
335335
'Error: No data to report.']
@@ -338,7 +338,7 @@ def test_cli_call_verbosity_fd(capfd):
338338
out, err = capfd.readouterr()
339339
assert out == ''
340340
assert err.splitlines() == [
341-
'Parsing file: /dev/null',
341+
'Parsing file: %s' % os.devnull,
342342
'source_files: []',
343343
'Not writing coverage file: no data to report!',
344344
'Error: No data to report.']
@@ -490,7 +490,7 @@ def test_report_profile_or_data_file(runner, tmpdir):
490490
'report', '--data-file', os.devnull])
491491
cov_exc = 'CoverageException: Doesn\'t seem to be a coverage.py data file'
492492
assert result.output.splitlines()[-1] == \
493-
'Error: Coverage could not read data_file: /dev/null (%s)' % cov_exc
493+
'Error: Coverage could not read data_file: %s (%s)' % (os.devnull, cov_exc)
494494
assert result.exit_code == 1
495495

496496
with tmpdir.as_cwd():

tests/test_coveragepy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sys
23

34
import attr
@@ -165,7 +166,7 @@ def test_coveragewrapper(coverage_fileobj, devnull):
165166
with pytest.raises(CoverageWrapperException) as excinfo:
166167
CoverageWrapper(data_file=devnull.name)
167168
assert excinfo.value.args == (
168-
'Coverage could not read data_file: /dev/null',)
169+
'Coverage could not read data_file: %s' % os.devnull,)
169170

170171
f = StringIO()
171172
with pytest.raises(CoverageWrapperException) as excinfo:

tests/test_main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
import textwrap
34

45
import coverage
@@ -39,7 +40,7 @@ def test_profile_fname_or_fobj(caplog, devnull):
3940
with caplog.at_level(logging.DEBUG, logger='covimerage'):
4041
Profile(devnull).parse()
4142
msgs = [(r.levelname, r.message) for r in caplog.records]
42-
assert msgs == [('DEBUG', 'Parsing file: /dev/null')]
43+
assert msgs == [('DEBUG', 'Parsing file: %s' % os.devnull)]
4344

4445
fileobj = StringIO('')
4546
with caplog.at_level(logging.DEBUG, logger='covimerage'):

tests/test_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
from covimerage._compat import StringIO
24

35

@@ -27,7 +29,7 @@ def test_get_fname_and_fobj_and_str(devnull):
2729
F = get_fname_and_fobj_and_str
2830
assert F('foo') == ('foo', None, 'foo')
2931
assert F(None) == (None, None, 'None')
30-
assert F(devnull) == ('/dev/null', devnull, '/dev/null')
32+
assert F(devnull) == (os.devnull, devnull, os.devnull)
3133
s = StringIO('')
3234
assert F(s) == (None, s, str(s))
3335

0 commit comments

Comments
 (0)