@@ -351,61 +351,12 @@ def test_func1(self):
351351 reprec .assertoutcome (skipped = 1 )
352352
353353
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-
406354class TestTrialUnittest (object ):
407355 def setup_class (cls ):
408356 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' )
409360
410361 def test_trial_testcase_runtest_not_collected (self , testdir ):
411362 testdir .makepyfile ("""
@@ -415,7 +366,7 @@ class TC(TestCase):
415366 def test_hello(self):
416367 pass
417368 """ )
418- reprec = testdir .inline_run ()
369+ reprec = testdir .inline_run (* self . ignore_unclosed_socket_warning )
419370 reprec .assertoutcome (passed = 1 )
420371 testdir .makepyfile ("""
421372 from twisted.trial.unittest import TestCase
@@ -424,7 +375,7 @@ class TC(TestCase):
424375 def runTest(self):
425376 pass
426377 """ )
427- reprec = testdir .inline_run ()
378+ reprec = testdir .inline_run (* self . ignore_unclosed_socket_warning )
428379 reprec .assertoutcome (passed = 1 )
429380
430381 def test_trial_exceptions_with_skips (self , testdir ):
@@ -462,7 +413,7 @@ def test_method(self):
462413 """ )
463414 from _pytest .compat import _is_unittest_unexpected_success_a_failure
464415 should_fail = _is_unittest_unexpected_success_a_failure ()
465- result = testdir .runpytest ("-rxs" )
416+ result = testdir .runpytest ("-rxs" , * self . ignore_unclosed_socket_warning )
466417 result .stdout .fnmatch_lines_random ([
467418 "*XFAIL*test_trial_todo*" ,
468419 "*trialselfskip*" ,
@@ -537,6 +488,50 @@ def test_hello(self):
537488 child .expect ("hellopdb" )
538489 child .sendeof ()
539490
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+
540535
541536def test_djangolike_testcase (testdir ):
542537 # contributed from Morten Breekevold
0 commit comments