@@ -362,6 +362,132 @@ def test_some(arg1):
362
362
reprec .assertoutcome (passed = 1 )
363
363
364
364
365
+ def test_issues10_xfail (testdir ):
366
+ testdir .makepyfile ("""
367
+ import pytest
368
+ def division(a, b):
369
+ return a / b
370
+
371
+ @pytest.fixture(params=[0])
372
+ def zero(request):
373
+ return request.param
374
+
375
+ @pytest.mark.parametrize(('a', 'b'), [
376
+ pytest.mark.xfail((1, pytest.lazy_fixture('zero')), reason=ZeroDivisionError)
377
+ ])
378
+ def test_division(a, b):
379
+ division(a, b)
380
+ """ )
381
+ reprec = testdir .inline_run ('-s' , '-v' )
382
+ reprec .assertoutcome (skipped = 1 )
383
+
384
+
385
+ def test_issues11_autouse_fixture_in_test_class (testdir ):
386
+ testdir .makepyfile ("""
387
+ import pytest
388
+
389
+ class TestModels(object):
390
+ @pytest.fixture(autouse=True)
391
+ def setup(self):
392
+ self.var = 15
393
+
394
+ def test_model_a(self):
395
+ assert self.var == 15
396
+
397
+ def test_model_b(self):
398
+ assert self.var == 15
399
+
400
+ """ )
401
+ reprec = testdir .inline_run ('-s' , '-v' )
402
+ reprec .assertoutcome (passed = 2 )
403
+
404
+
405
+ def test_issues12_skip_test_function (testdir ):
406
+ testdir .makepyfile ("""
407
+ import pytest
408
+
409
+ @pytest.fixture
410
+ def one():
411
+ return 1
412
+
413
+ @pytest.mark.parametrize('a', [
414
+ pytest.mark.skip((pytest.lazy_fixture('one'),), reason='skip')
415
+ ])
416
+ def test_skip1(a):
417
+ assert a == 1
418
+
419
+ @pytest.mark.skip(reason='skip')
420
+ @pytest.mark.parametrize('a', [
421
+ pytest.lazy_fixture('one')
422
+ ])
423
+ def test_skip2(a):
424
+ assert a == 1
425
+ """ )
426
+ reprec = testdir .inline_run ('-s' , '-v' )
427
+ reprec .assertoutcome (skipped = 2 )
428
+
429
+
430
+ def test_issues12_skip_test_method (testdir ):
431
+ testdir .makepyfile ("""
432
+ import pytest
433
+
434
+ class TestModels:
435
+ @pytest.fixture
436
+ def one(self):
437
+ return 1
438
+
439
+ @pytest.mark.skip(reason='skip this')
440
+ @pytest.mark.parametrize('a', [
441
+ pytest.lazy_fixture('one')
442
+ ])
443
+ def test_model_a(self, a):
444
+ assert a == 1
445
+
446
+ @pytest.mark.parametrize('a', [
447
+ pytest.mark.skip((pytest.lazy_fixture('one'),), reason='skip this')
448
+ ])
449
+ def test_model_b(self, a):
450
+ assert a == 1
451
+ """ )
452
+ reprec = testdir .inline_run ('-s' , '-v' )
453
+ reprec .assertoutcome (skipped = 2 )
454
+
455
+
456
+ def test_issues12_lf_as_method_of_test_class (testdir ):
457
+ testdir .makepyfile ("""
458
+ import pytest
459
+
460
+ class TestModels:
461
+ @pytest.fixture
462
+ def one(self):
463
+ return 1
464
+
465
+ @pytest.mark.parametrize('a', [
466
+ pytest.lazy_fixture('one')
467
+ ])
468
+ def test_lf(self, a):
469
+ assert a == 1
470
+ """ )
471
+ reprec = testdir .inline_run ('-s' , '-v' )
472
+ reprec .assertoutcome (passed = 1 )
473
+
474
+
475
+ def test_issues13_unittest_testcase_class_should_not_fail (testdir ):
476
+ testdir .makepyfile ("""
477
+ import unittest
478
+ import pytest
479
+
480
+ class TestModels(unittest.TestCase):
481
+ def test_models(self):
482
+ assert True
483
+
484
+ def test_models_fail(self):
485
+ assert False
486
+ """ )
487
+ reprec = testdir .inline_run ('-s' , '-v' )
488
+ reprec .assertoutcome (passed = 1 , failed = 1 )
489
+
490
+
365
491
def lf (fname ):
366
492
return lazy_fixture (fname )
367
493
0 commit comments