@@ -25,6 +25,11 @@ def test_foo():
25
25
assert False
26
26
'''
27
27
28
+ COVERAGERC_SOURCE = '''\
29
+ [run]
30
+ source = .
31
+ '''
32
+
28
33
SCRIPT_CHILD = '''
29
34
import sys
30
35
@@ -96,7 +101,7 @@ def test_central(testdir):
96
101
script = testdir .makepyfile (SCRIPT )
97
102
98
103
result = testdir .runpytest ('-v' ,
99
- '--cov=%s' % script .dirpath (),
104
+ '--cov' , '--cov-source =%s' % script .dirpath (),
100
105
'--cov-report=term-missing' ,
101
106
script )
102
107
@@ -108,11 +113,52 @@ def test_central(testdir):
108
113
assert result .ret == 0
109
114
110
115
116
+ def test_central_nonspecific (testdir ):
117
+ script = testdir .makepyfile (SCRIPT )
118
+
119
+ result = testdir .runpytest ('-v' ,
120
+ '--cov' ,
121
+ '--cov-report=term-missing' ,
122
+ script )
123
+
124
+ result .stdout .fnmatch_lines ([
125
+ '*- coverage: platform *, python * -*' ,
126
+ 'test_central_nonspecific * %s *' % SCRIPT_RESULT ,
127
+ '*10 passed*'
128
+ ])
129
+
130
+ # multi-module coverage report
131
+ assert result .stdout .lines [- 3 ].startswith ('TOTAL ' )
132
+
133
+ assert result .ret == 0
134
+
135
+
136
+ def test_central_coveragerc (testdir ):
137
+ script = testdir .makepyfile (SCRIPT )
138
+ testdir .tmpdir .join ('.coveragerc' ).write (COVERAGERC_SOURCE )
139
+
140
+ result = testdir .runpytest ('-v' ,
141
+ '--cov' ,
142
+ '--cov-report=term-missing' ,
143
+ script )
144
+
145
+ result .stdout .fnmatch_lines ([
146
+ '*- coverage: platform *, python * -*' ,
147
+ 'test_central_coveragerc * %s *' % SCRIPT_RESULT ,
148
+ '*10 passed*' ,
149
+ ])
150
+
151
+ # single-module coverage report
152
+ assert result .stdout .lines [- 3 ].startswith ('test_central_coveragerc ' )
153
+
154
+ assert result .ret == 0
155
+
156
+
111
157
def test_no_cov_on_fail (testdir ):
112
158
script = testdir .makepyfile (SCRIPT_FAIL )
113
159
114
160
result = testdir .runpytest ('-v' ,
115
- '--cov=%s' % script .dirpath (),
161
+ '--cov' , '--cov-source =%s' % script .dirpath (),
116
162
'--cov-report=term-missing' ,
117
163
'--no-cov-on-fail' ,
118
164
script )
@@ -125,7 +171,7 @@ def test_dist_collocated(testdir):
125
171
script = testdir .makepyfile (SCRIPT )
126
172
127
173
result = testdir .runpytest ('-v' ,
128
- '--cov=%s' % script .dirpath (),
174
+ '--cov' , '--cov-source =%s' % script .dirpath (),
129
175
'--cov-report=term-missing' ,
130
176
'--dist=load' ,
131
177
'--tx=2*popen' ,
@@ -145,7 +191,7 @@ def test_dist_not_collocated(testdir):
145
191
dir2 = testdir .mkdir ('dir2' )
146
192
147
193
result = testdir .runpytest ('-v' ,
148
- '--cov=%s' % script .dirpath (),
194
+ '--cov' , '--cov-source =%s' % script .dirpath (),
149
195
'--cov-report=term-missing' ,
150
196
'--dist=load' ,
151
197
'--tx=popen//chdir=%s' % dir1 ,
@@ -167,7 +213,7 @@ def test_central_subprocess(testdir):
167
213
parent_script = scripts .dirpath ().join ('parent_script.py' )
168
214
169
215
result = testdir .runpytest ('-v' ,
170
- '--cov=%s' % scripts .dirpath (),
216
+ '--cov' , '--cov-source =%s' % scripts .dirpath (),
171
217
'--cov-report=term-missing' ,
172
218
parent_script )
173
219
@@ -185,7 +231,7 @@ def test_dist_subprocess_collocated(testdir):
185
231
parent_script = scripts .dirpath ().join ('parent_script.py' )
186
232
187
233
result = testdir .runpytest ('-v' ,
188
- '--cov=%s' % scripts .dirpath (),
234
+ '--cov' , '--cov-source =%s' % scripts .dirpath (),
189
235
'--cov-report=term-missing' ,
190
236
'--dist=load' ,
191
237
'--tx=2*popen' ,
@@ -209,7 +255,7 @@ def test_dist_subprocess_not_collocated(testdir, tmpdir):
209
255
dir2 = tmpdir .mkdir ('dir2' )
210
256
211
257
result = testdir .runpytest ('-v' ,
212
- '--cov=%s' % scripts .dirpath (),
258
+ '--cov' , '--cov-source =%s' % scripts .dirpath (),
213
259
'--cov-report=term-missing' ,
214
260
'--dist=load' ,
215
261
'--tx=popen//chdir=%s' % dir1 ,
@@ -230,7 +276,7 @@ def test_empty_report(testdir):
230
276
script = testdir .makepyfile (SCRIPT )
231
277
232
278
result = testdir .runpytest ('-v' ,
233
- '--cov=non_existent_module' ,
279
+ '--cov' , '--cov-source =non_existent_module' ,
234
280
'--cov-report=term-missing' ,
235
281
script )
236
282
@@ -253,7 +299,7 @@ def test_dist_missing_data(testdir):
253
299
script = testdir .makepyfile (SCRIPT )
254
300
255
301
result = testdir .runpytest ('-v' ,
256
- '--cov=%s' % script .dirpath (),
302
+ '--cov' , '--cov-source =%s' % script .dirpath (),
257
303
'--cov-report=term-missing' ,
258
304
'--dist=load' ,
259
305
'--tx=popen//python=%s' % exe ,
@@ -269,7 +315,7 @@ def test_funcarg(testdir):
269
315
script = testdir .makepyfile (SCRIPT_FUNCARG )
270
316
271
317
result = testdir .runpytest ('-v' ,
272
- '--cov=%s' % script .dirpath (),
318
+ '--cov' , '--cov-source =%s' % script .dirpath (),
273
319
'--cov-report=term-missing' ,
274
320
script )
275
321
@@ -299,7 +345,7 @@ def test_multiprocessing_subprocess(testdir):
299
345
script = testdir .makepyfile (MULTIPROCESSING_SCRIPT )
300
346
301
347
result = testdir .runpytest ('-v' ,
302
- '--cov=%s' % script .dirpath (),
348
+ '--cov' , '--cov-source =%s' % script .dirpath (),
303
349
'--cov-report=term-missing' ,
304
350
script )
305
351
@@ -340,7 +386,7 @@ def test_cover_conftest(testdir):
340
386
testdir .makeconftest (CONFTEST )
341
387
script = testdir .makepyfile (BASIC_TEST )
342
388
result = testdir .runpytest ('-v' ,
343
- '--cov=%s' % script .dirpath (),
389
+ '--cov' , '--cov-source =%s' % script .dirpath (),
344
390
'--cov-report=term-missing' ,
345
391
script )
346
392
assert result .ret == 0
@@ -352,7 +398,7 @@ def test_cover_conftest_dist(testdir):
352
398
testdir .makeconftest (CONFTEST )
353
399
script = testdir .makepyfile (BASIC_TEST )
354
400
result = testdir .runpytest ('-v' ,
355
- '--cov=%s' % script .dirpath (),
401
+ '--cov' , '--cov-source =%s' % script .dirpath (),
356
402
'--cov-report=term-missing' ,
357
403
'--dist=load' ,
358
404
'--tx=2*popen' ,
@@ -388,7 +434,7 @@ def test_coveragerc(testdir):
388
434
script = testdir .makepyfile (EXCLUDED_TEST )
389
435
result = testdir .runpytest ('-v' ,
390
436
'--cov-config=coveragerc' ,
391
- '--cov=%s' % script .dirpath (),
437
+ '--cov' , '--cov-source =%s' % script .dirpath (),
392
438
'--cov-report=term-missing' ,
393
439
script )
394
440
assert result .ret == 0
@@ -400,7 +446,7 @@ def test_coveragerc_dist(testdir):
400
446
script = testdir .makepyfile (EXCLUDED_TEST )
401
447
result = testdir .runpytest ('-v' ,
402
448
'--cov-config=coveragerc' ,
403
- '--cov=%s' % script .dirpath (),
449
+ '--cov' , '--cov-source =%s' % script .dirpath (),
404
450
'--cov-report=term-missing' ,
405
451
'-n' , '2' ,
406
452
script )
@@ -422,7 +468,7 @@ def test_basic():
422
468
def test_clear_environ (testdir ):
423
469
script = testdir .makepyfile (CLEAR_ENVIRON_TEST )
424
470
result = testdir .runpytest ('-v' ,
425
- '--cov=%s' % script .dirpath (),
471
+ '--cov' , '--cov-source =%s' % script .dirpath (),
426
472
'--cov-report=term-missing' ,
427
473
script )
428
474
assert result .ret == 0
@@ -445,7 +491,7 @@ def test_dist_boxed(testdir):
445
491
script = testdir .makepyfile (SCRIPT_SIMPLE )
446
492
447
493
result = testdir .runpytest ('-v' ,
448
- '--cov=%s' % script .dirpath (),
494
+ '--cov' , '--cov-source =%s' % script .dirpath (),
449
495
'--boxed' ,
450
496
script )
451
497
@@ -461,3 +507,16 @@ def test_not_started_plugin_does_not_fail(testdir):
461
507
plugin = pytest_cov .CovPlugin (None , None , start = False )
462
508
plugin .pytest_sessionfinish (None , None )
463
509
plugin .pytest_terminal_summary (None )
510
+
511
+
512
+ def test_deprecation_warning (testdir ):
513
+ script = testdir .makepyfile (SCRIPT )
514
+
515
+ result = testdir .runpytest ('-v' ,
516
+ '--cov=%s' % script .dirpath (),
517
+ script )
518
+
519
+ result .stdout .fnmatch_lines ([
520
+ 'Deprecation warning: * --cov-source instead*'
521
+ ])
522
+ assert result .ret == 0
0 commit comments