summaryrefslogtreecommitdiffstats
path: root/tests/test_python34.py
blob: 2fd3179740073b1a47626edb177cf884628d5eb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 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:
        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 %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")

    @pytest.mark.skipIf("TestNewPython34Modules.skip_python3")
    def test_python34_ensurepip(self):
        python34_module("ensurepip")

    @pytest.mark.skipIf("TestPython3Installed.skip_python3")
    def test_python34_enum(self):
        python34_module("enum")

    @pytest.mark.skipIf("TestPython3Installed.skip_python3")
    def test_python34_pathlib(self):
        python34_module("pathlib")

    @pytest.mark.skipIf("TestPython3Installed.skip_python3")
    def test_python34_selectors(self):
        python34_module("selectors")

    @pytest.mark.skipIf("TestPython3Installed.skip_python3")
    def test_python34_statistics(self):
        python34_module("statistics")

    @pytest.mark.skipIf("TestPython3Installed.skip_python3")
    def test_python34_tracemalloc(self):
        python34_module("tracemalloc")