@@ -362,6 +362,129 @@ 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(self):
395
+ assert self.var == 15
396
+
397
+ """ )
398
+ reprec = testdir .inline_run ('-s' , '-v' )
399
+ reprec .assertoutcome (passed = 1 )
400
+
401
+
402
+ def test_issues12_skip_test_function (testdir ):
403
+ testdir .makepyfile ("""
404
+ import pytest
405
+
406
+ @pytest.fixture
407
+ def one():
408
+ return 1
409
+
410
+ @pytest.mark.parametrize('a', [
411
+ pytest.mark.skip((pytest.lazy_fixture('one'),), reason='skip')
412
+ ])
413
+ def test_skip1(a):
414
+ assert a == 1
415
+
416
+ @pytest.mark.skip(reason='skip')
417
+ @pytest.mark.parametrize('a', [
418
+ pytest.lazy_fixture('one')
419
+ ])
420
+ def test_skip2(a):
421
+ assert a == 1
422
+ """ )
423
+ reprec = testdir .inline_run ('-s' , '-v' )
424
+ reprec .assertoutcome (skipped = 2 )
425
+
426
+
427
+ def test_issues12_skip_test_method (testdir ):
428
+ testdir .makepyfile ("""
429
+ import pytest
430
+
431
+ class TestModels:
432
+ @pytest.fixture
433
+ def one(self):
434
+ return 1
435
+
436
+ @pytest.mark.skip(reason='skip this')
437
+ @pytest.mark.parametrize('a', [
438
+ pytest.lazy_fixture('one')
439
+ ])
440
+ def test_model_a(self, a):
441
+ assert a == 1
442
+
443
+ @pytest.mark.parametrize('a', [
444
+ pytest.mark.skip((pytest.lazy_fixture('one'),), reason='skip this')
445
+ ])
446
+ def test_model_b(self, a):
447
+ assert a == 1
448
+ """ )
449
+ reprec = testdir .inline_run ('-s' , '-v' )
450
+ reprec .assertoutcome (skipped = 2 )
451
+
452
+
453
+ def test_issues12_lf_as_method_of_test_class (testdir ):
454
+ testdir .makepyfile ("""
455
+ import pytest
456
+
457
+ class TestModels:
458
+ @pytest.fixture
459
+ def one(self):
460
+ return 1
461
+
462
+ @pytest.mark.parametrize('a', [
463
+ pytest.lazy_fixture('one')
464
+ ])
465
+ def test_lf(self, a):
466
+ assert a == 1
467
+ """ )
468
+ reprec = testdir .inline_run ('-s' , '-v' )
469
+ reprec .assertoutcome (passed = 1 )
470
+
471
+
472
+ def test_issues13_unittest_testcase_class_should_not_fail (testdir ):
473
+ testdir .makepyfile ("""
474
+ import unittest
475
+ import pytest
476
+
477
+ class TestModels(unittest.TestCase):
478
+ def test_models(self):
479
+ assert True
480
+
481
+ def test_models_fail(self):
482
+ assert False
483
+ """ )
484
+ reprec = testdir .inline_run ('-s' , '-v' )
485
+ reprec .assertoutcome (passed = 1 , failed = 1 )
486
+
487
+
365
488
def lf (fname ):
366
489
return lazy_fixture (fname )
367
490
0 commit comments