From 7589c42e2e18720d3acae57f9ea05d4fe30b30ac Mon Sep 17 00:00:00 2001 From: Tim Orling Date: Wed, 5 Oct 2016 22:31:15 -0700 Subject: add python3 and python34 tests; add build_and_run.sh Signed-off-by: Tim Orling --- tests/test_python34.py | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'tests/test_python34.py') 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") -- cgit