diff options
Diffstat (limited to 'tests/test_python34.py')
-rw-r--r-- | tests/test_python34.py | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/tests/test_python34.py b/tests/test_python34.py index ce92c7b..2fd3179 100644 --- a/tests/test_python34.py +++ b/tests/test_python34.py @@ -16,33 +16,51 @@ import os import pytest import shlex +import sys from subprocess import Popen, PIPE +def python3_cli(): + try: + Popen("python3").communicate()[0] + return True + except OSError: + pytest.fail("OSError: python3 not installed") + return False + def python34_module(modulename): - cmd = shlex.split("python3 -m {}" % modulename) - output = Popen(cmd, stdout=PIPE).communicate()[0] - return output - + cmd = shlex.split("python3 -m %s" % modulename) + try: + Popen(cmd, stdout=PIPE).communicate()[0] + except: + pytest.fail("Error: python module %s not present" % modulename) class TestNewPython34Modules: + skip_python3 = python3_cli() + @pytest.mark.skipIf("TestNewPython34Modules.skip_python3") def test_python34_asyncio(self): python34_module("asyncio") - def test_python34_ensurepip(self, python34_module("ensurepip")): + @pytest.mark.skipIf("TestNewPython34Modules.skip_python3") + def test_python34_ensurepip(self): python34_module("ensurepip") - def test_python34_enum(self, python34_module("enum")): + @pytest.mark.skipIf("TestPython3Installed.skip_python3") + def test_python34_enum(self): python34_module("enum") - def test_python34_pathlib(self, python34_module("pathlib")): + @pytest.mark.skipIf("TestPython3Installed.skip_python3") + def test_python34_pathlib(self): python34_module("pathlib") - def test_python34_selectors(self, python34_module("selectors")): + @pytest.mark.skipIf("TestPython3Installed.skip_python3") + def test_python34_selectors(self): python34_module("selectors") - def test_python34_statistics(self, python34_module("statistics")): + @pytest.mark.skipIf("TestPython3Installed.skip_python3") + def test_python34_statistics(self): python34_module("statistics") - def test_python34_tracemalloc(self, python34_module("tracemalloc")): + @pytest.mark.skipIf("TestPython3Installed.skip_python3") + def test_python34_tracemalloc(self): python34_module("tracemalloc") |