@@ -351,61 +351,12 @@ def test_func1(self):
351
351
reprec .assertoutcome (skipped = 1 )
352
352
353
353
354
- def test_trial_testcase_skip_property (testdir ):
355
- pytest .importorskip ('twisted.trial.unittest' )
356
- testpath = testdir .makepyfile ("""
357
- from twisted.trial import unittest
358
- class MyTestCase(unittest.TestCase):
359
- skip = 'dont run'
360
- def test_func(self):
361
- pass
362
- """ )
363
- reprec = testdir .inline_run (testpath , "-s" )
364
- reprec .assertoutcome (skipped = 1 )
365
-
366
-
367
- def test_trial_testfunction_skip_property (testdir ):
368
- pytest .importorskip ('twisted.trial.unittest' )
369
- testpath = testdir .makepyfile ("""
370
- from twisted.trial import unittest
371
- class MyTestCase(unittest.TestCase):
372
- def test_func(self):
373
- pass
374
- test_func.skip = 'dont run'
375
- """ )
376
- reprec = testdir .inline_run (testpath , "-s" )
377
- reprec .assertoutcome (skipped = 1 )
378
-
379
-
380
- def test_trial_testcase_todo_property (testdir ):
381
- pytest .importorskip ('twisted.trial.unittest' )
382
- testpath = testdir .makepyfile ("""
383
- from twisted.trial import unittest
384
- class MyTestCase(unittest.TestCase):
385
- todo = 'dont run'
386
- def test_func(self):
387
- assert 0
388
- """ )
389
- reprec = testdir .inline_run (testpath , "-s" )
390
- reprec .assertoutcome (skipped = 1 )
391
-
392
-
393
- def test_trial_testfunction_todo_property (testdir ):
394
- pytest .importorskip ('twisted.trial.unittest' )
395
- testpath = testdir .makepyfile ("""
396
- from twisted.trial import unittest
397
- class MyTestCase(unittest.TestCase):
398
- def test_func(self):
399
- assert 0
400
- test_func.todo = 'dont run'
401
- """ )
402
- reprec = testdir .inline_run (testpath , "-s" )
403
- reprec .assertoutcome (skipped = 1 )
404
-
405
-
406
354
class TestTrialUnittest (object ):
407
355
def setup_class (cls ):
408
356
cls .ut = pytest .importorskip ("twisted.trial.unittest" )
357
+ # on windows trial uses a socket for a reactor and apparently doesn't close it properly
358
+ # https://twistedmatrix.com/trac/ticket/9227
359
+ cls .ignore_unclosed_socket_warning = ('-W' , 'always' )
409
360
410
361
def test_trial_testcase_runtest_not_collected (self , testdir ):
411
362
testdir .makepyfile ("""
@@ -415,7 +366,7 @@ class TC(TestCase):
415
366
def test_hello(self):
416
367
pass
417
368
""" )
418
- reprec = testdir .inline_run ()
369
+ reprec = testdir .inline_run (* self . ignore_unclosed_socket_warning )
419
370
reprec .assertoutcome (passed = 1 )
420
371
testdir .makepyfile ("""
421
372
from twisted.trial.unittest import TestCase
@@ -424,7 +375,7 @@ class TC(TestCase):
424
375
def runTest(self):
425
376
pass
426
377
""" )
427
- reprec = testdir .inline_run ()
378
+ reprec = testdir .inline_run (* self . ignore_unclosed_socket_warning )
428
379
reprec .assertoutcome (passed = 1 )
429
380
430
381
def test_trial_exceptions_with_skips (self , testdir ):
@@ -462,7 +413,7 @@ def test_method(self):
462
413
""" )
463
414
from _pytest .compat import _is_unittest_unexpected_success_a_failure
464
415
should_fail = _is_unittest_unexpected_success_a_failure ()
465
- result = testdir .runpytest ("-rxs" )
416
+ result = testdir .runpytest ("-rxs" , * self . ignore_unclosed_socket_warning )
466
417
result .stdout .fnmatch_lines_random ([
467
418
"*XFAIL*test_trial_todo*" ,
468
419
"*trialselfskip*" ,
@@ -537,6 +488,50 @@ def test_hello(self):
537
488
child .expect ("hellopdb" )
538
489
child .sendeof ()
539
490
491
+ def test_trial_testcase_skip_property (self , testdir ):
492
+ testpath = testdir .makepyfile ("""
493
+ from twisted.trial import unittest
494
+ class MyTestCase(unittest.TestCase):
495
+ skip = 'dont run'
496
+ def test_func(self):
497
+ pass
498
+ """ )
499
+ reprec = testdir .inline_run (testpath , "-s" )
500
+ reprec .assertoutcome (skipped = 1 )
501
+
502
+ def test_trial_testfunction_skip_property (self , testdir ):
503
+ testpath = testdir .makepyfile ("""
504
+ from twisted.trial import unittest
505
+ class MyTestCase(unittest.TestCase):
506
+ def test_func(self):
507
+ pass
508
+ test_func.skip = 'dont run'
509
+ """ )
510
+ reprec = testdir .inline_run (testpath , "-s" )
511
+ reprec .assertoutcome (skipped = 1 )
512
+
513
+ def test_trial_testcase_todo_property (self , testdir ):
514
+ testpath = testdir .makepyfile ("""
515
+ from twisted.trial import unittest
516
+ class MyTestCase(unittest.TestCase):
517
+ todo = 'dont run'
518
+ def test_func(self):
519
+ assert 0
520
+ """ )
521
+ reprec = testdir .inline_run (testpath , "-s" )
522
+ reprec .assertoutcome (skipped = 1 )
523
+
524
+ def test_trial_testfunction_todo_property (self , testdir ):
525
+ testpath = testdir .makepyfile ("""
526
+ from twisted.trial import unittest
527
+ class MyTestCase(unittest.TestCase):
528
+ def test_func(self):
529
+ assert 0
530
+ test_func.todo = 'dont run'
531
+ """ )
532
+ reprec = testdir .inline_run (testpath , "-s" , * self .ignore_unclosed_socket_warning )
533
+ reprec .assertoutcome (skipped = 1 )
534
+
540
535
541
536
def test_djangolike_testcase (testdir ):
542
537
# contributed from Morten Breekevold
0 commit comments