# Copyright (C) 2016 Intel Corporation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import os import pytest import shlex import sys from subprocess import Popen, PIPE def python3_cli(): try: output = Popen("python3").communicate()[0] return output except: pytest.mark.xfail("Error: python3 not installed") finally: return False def python34_module(modulename): 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 TestPython3Installed: @pytest.fixture def python3_cli(self): try: output = Popen("python3").communicate()[0] return output except: pytest.mark.xfail("Error: python3 not installed") finally: return False def test_python3_installed(self, python3_cli): if not python3_cli: pytest.fail("Error: python3 not installed") else: pass @pytest.mark.skipif(TestPython3Installed.python3_cli, reason="no python3 installed") class TestNewPython34Modules: skip_python3 = python3_cli() def test_python34_asyncio(self): python34_module("asyncio") def test_python34_ensurepip(self): python34_module("ensurepip") def test_python34_enum(self): python34_module("enum") def test_python34_pathlib(self): python34_module("pathlib") def test_python34_selectors(self): python34_module("selectors") def test_python34_statistics(self): python34_module("statistics") def test_python34_tracemalloc(self): python34_module("tracemalloc")