Skip to content

Commit

Permalink
update 3.11 and 3.12 tests to use submodules (#164)
Browse files Browse the repository at this point in the history
* 3.12 tests use submodules

* update travis test runner for test submodules

* 3.11 tests use submodules

* use elif for test submodule cases

* fix typo in travis elif
  • Loading branch information
mmckerns authored Oct 7, 2023
1 parent a65a783 commit 83e728f
Show file tree
Hide file tree
Showing 40 changed files with 382 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ script:
- cd py$PYVERSION #XXX: bash script may require tests run from root
- if [[ $COVERAGE == "true" ]]; then cp ../.coveragerc .coveragerc ; fi
- for test in multiprocess/tests/__init__.py; do echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; done
- if [[ $PYVERSION == *"py3"* ]]; then for test in multiprocess/tests/test_multiprocessing_fork.py; do echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; done ; else for test in multiprocess/tests/*.py; do if [[ $test != *"__"* && $test != *"mp_"* ]]; then echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; fi; done ; fi
- if [[ $PYVERSION == *"py3"* ]]; then for test in multiprocess/tests/test_multiprocessing_fork.py; do echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; done ; elif [[ $PYVERSION == "3.11" || $PYVERSION == "3.12" ]]; then for test in multiprocess/tests/*.py multiprocess/tests/test_*/*.py; do if [[ $test != *"__"* && $test != *"mp_"* ]]; then echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; fi ; done ; else for test in multiprocess/tests/*.py; do if [[ $test != *"__"* && $test != *"mp_"* ]]; then echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; fi; done ; fi
- cd ..

after_success:
Expand Down
3 changes: 1 addition & 2 deletions py3.11/multiprocess/tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
shell = sys.platform[:3] == 'win'

suite = os.path.dirname(__file__) or os.path.curdir
tests = glob.glob(suite + os.path.sep + 'test_*.py')
tests = glob.glob(suite + os.path.sep + '__init__.py') + \
[i for i in tests if 'main' not in i]
glob.glob(suite + os.path.sep + '*' + os.path.sep + '__init__.py')


if __name__ == '__main__':
Expand Down
19 changes: 0 additions & 19 deletions py3.11/multiprocess/tests/test_multiprocessing_fork.py

This file was deleted.

36 changes: 36 additions & 0 deletions py3.11/multiprocess/tests/test_multiprocessing_fork/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os.path
import sys
import unittest
from test import support
import glob
import subprocess as sp
python = sys.executable
try:
import pox
python = pox.which_python(version=True) or python
except ImportError:
pass
shell = sys.platform[:3] == 'win'

if support.PGO:
raise unittest.SkipTest("test is not helpful for PGO")

if sys.platform == "win32":
raise unittest.SkipTest("fork is not available on Windows")

if sys.platform == 'darwin':
raise unittest.SkipTest("test may crash on macOS (bpo-33725)")

suite = os.path.dirname(__file__) or os.path.curdir
tests = glob.glob(suite + os.path.sep + 'test_*.py')


if __name__ == '__main__':

failed = 0
for test in tests:
p = sp.Popen([python, test], shell=shell).wait()
if p:
failed = 1
print('')
exit(failed)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'fork', only_type="manager")

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'fork', exclude_types=True)

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'fork', only_type="processes")

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'fork', only_type="threads")

if __name__ == '__main__':
unittest.main()
16 changes: 0 additions & 16 deletions py3.11/multiprocess/tests/test_multiprocessing_forkserver.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os.path
import sys
import unittest
from test import support
import glob
import subprocess as sp
python = sys.executable
try:
import pox
python = pox.which_python(version=True) or python
except ImportError:
pass
shell = sys.platform[:3] == 'win'

if support.PGO:
raise unittest.SkipTest("test is not helpful for PGO")

if sys.platform == "win32":
raise unittest.SkipTest("forkserver is not available on Windows")

suite = os.path.dirname(__file__) or os.path.curdir
tests = glob.glob(suite + os.path.sep + 'test_*.py')


if __name__ == '__main__':

failed = 0
for test in tests:
p = sp.Popen([python, test], shell=shell).wait()
if p:
failed = 1
print('')
exit(failed)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'forkserver', only_type="manager")

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'forkserver', exclude_types=True)

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'forkserver', only_type="processes")

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'forkserver', only_type="threads")

if __name__ == '__main__':
unittest.main()
12 changes: 0 additions & 12 deletions py3.11/multiprocess/tests/test_multiprocessing_spawn.py

This file was deleted.

30 changes: 30 additions & 0 deletions py3.11/multiprocess/tests/test_multiprocessing_spawn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os.path
import sys
import unittest
from test import support
import glob
import subprocess as sp
python = sys.executable
try:
import pox
python = pox.which_python(version=True) or python
except ImportError:
pass
shell = sys.platform[:3] == 'win'

if support.PGO:
raise unittest.SkipTest("test is not helpful for PGO")

suite = os.path.dirname(__file__) or os.path.curdir
tests = glob.glob(suite + os.path.sep + 'test_*.py')


if __name__ == '__main__':

failed = 0
for test in tests:
p = sp.Popen([python, test], shell=shell).wait()
if p:
failed = 1
print('')
exit(failed)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'spawn', only_type="manager")

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'spawn', exclude_types=True)

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'spawn', only_type="processes")

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'spawn', only_type="threads")

if __name__ == '__main__':
unittest.main()
3 changes: 1 addition & 2 deletions py3.12/multiprocess/tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
shell = sys.platform[:3] == 'win'

suite = os.path.dirname(__file__) or os.path.curdir
tests = glob.glob(suite + os.path.sep + 'test_*.py')
tests = glob.glob(suite + os.path.sep + '__init__.py') + \
[i for i in tests if 'main' not in i]
glob.glob(suite + os.path.sep + '*' + os.path.sep + '__init__.py')


if __name__ == '__main__':
Expand Down
19 changes: 0 additions & 19 deletions py3.12/multiprocess/tests/test_multiprocessing_fork.py

This file was deleted.

36 changes: 36 additions & 0 deletions py3.12/multiprocess/tests/test_multiprocessing_fork/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os.path
import sys
import unittest
from test import support
import glob
import subprocess as sp
python = sys.executable
try:
import pox
python = pox.which_python(version=True) or python
except ImportError:
pass
shell = sys.platform[:3] == 'win'

if support.PGO:
raise unittest.SkipTest("test is not helpful for PGO")

if sys.platform == "win32":
raise unittest.SkipTest("fork is not available on Windows")

if sys.platform == 'darwin':
raise unittest.SkipTest("test may crash on macOS (bpo-33725)")

suite = os.path.dirname(__file__) or os.path.curdir
tests = glob.glob(suite + os.path.sep + 'test_*.py')


if __name__ == '__main__':

failed = 0
for test in tests:
p = sp.Popen([python, test], shell=shell).wait()
if p:
failed = 1
print('')
exit(failed)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'fork', only_type="manager")

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'fork', exclude_types=True)

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'fork', only_type="processes")

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from multiprocess.tests import install_tests_in_module_dict

install_tests_in_module_dict(globals(), 'fork', only_type="threads")

if __name__ == '__main__':
unittest.main()
16 changes: 0 additions & 16 deletions py3.12/multiprocess/tests/test_multiprocessing_forkserver.py

This file was deleted.

Loading

0 comments on commit 83e728f

Please sign in to comment.