Skip to content

Commit

Permalink
Make tests compatible with rhel8
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Mar 13, 2024
1 parent e6b5db7 commit f052b40
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
- name: Install Ubuntu Packages
Expand Down
17 changes: 9 additions & 8 deletions komodoenv/__main__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from __future__ import print_function
import os
import sys
import re
import argparse
import logging
import distro
import os
import re
import subprocess
from typing import Tuple
from shutil import rmtree
import sys
from pathlib import Path
from shutil import rmtree
from typing import Tuple

import distro
from colors import blue, strip_color, yellow

from komodoenv.creator import Creator
from komodoenv.statfs import is_nfs
from colors import blue, yellow, strip_color


def get_release_maturity_text(release_path):
Expand Down
13 changes: 7 additions & 6 deletions komodoenv/creator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from pathlib import Path
import subprocess
import os
import distro
import subprocess
from importlib.metadata import distribution
from pathlib import Path
from textwrap import dedent

import distro
from colors import green, strip_color
from pkg_resources import get_distribution

from komodoenv.python import Python
from komodoenv.bundle import get_bundled_wheel
from komodoenv.python import Python


class _OpenChmod:
Expand Down Expand Up @@ -120,7 +121,7 @@ def create(self):
tracked-release = {self.trackpath.name}
mtime-release = 0
python-version = {self.srcpy.version_info[0]}.{self.srcpy.version_info[1]}
komodoenv-version = {get_distribution('komodoenv').version}
komodoenv-version = {distribution('komodoenv').version}
komodo-root = {self.komodo_root}
linux-dist = {distro.id() + distro.version_parts()[0]}
"""
Expand Down
13 changes: 7 additions & 6 deletions komodoenv/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@
to avoid any dependency on komodo during the update.
"""
import os
import platform
import re
import sys
import shutil
import platform
from typing import List
import sys
from argparse import ArgumentParser
from textwrap import dedent
from typing import List

try:
from distro import id as distro_id, version_parts as distro_versions
from distro import id as distro_id
from distro import version_parts as distro_versions
except ImportError:
# The 'distro' package isn't installed.
#
def distro_id():
return "rhel"

if "el7" in platform.platform():
if "el7" in platform.release():

def distro_versions():
return ("7", "0", "0")

elif "el8" in platform.platform():
elif "el8" in platform.release():

def distro_versions():
return ("8", "0", "0")
Expand Down
12 changes: 9 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import os
import platform
import re
import pytest
from typing import List, Optional
from pathlib import Path
from subprocess import check_output
from typing import List, Optional

import pytest


def rhel_version():
return "8" if "el8" in platform.release() else "7"


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -39,7 +45,7 @@ def komodo_root(tmp_path_factory, python38_path):
_install(python38_path, path / "2030.01.01-py38", ["numpy==1.19.1"])
_install(python38_path, path / "2030.02.00-py38")
_install(python38_path, path / "2030.03.00-py38-rhel9")
_install(python38_path, path / "bleeding-py38-rhel7")
_install(python38_path, path / f"bleeding-py38-rhel{rhel_version()}")

for chain in (
("2030.01", "2030.01-py3", "2030.01-py38", "2030.01.00-py38"),
Expand Down
4 changes: 3 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
from subprocess import PIPE, CalledProcessError, Popen, check_output

import pytest
from subprocess import Popen, PIPE, check_output, CalledProcessError

from komodoenv.__main__ import main as _main


Expand Down
45 changes: 26 additions & 19 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import pytest

import komodoenv.__main__ as main
from tests.conftest import rhel_version


@pytest.mark.parametrize(
"expect,track_name,name",
[
# Bleeding is py38, rhel7
("bleeding-py38-rhel7", "bleeding-py38", "bleeding"),
("bleeding-py38-rhel7", "bleeding-py38", "bleeding-py3"),
("bleeding-py38-rhel7", "bleeding-py38", "bleeding-py38"),
# Stable is py38, unspecified rhel
def generate_test_params_simple(rhel_version):
base_params = [
("2030.01.00-py38", "stable-py38", "stable"),
("2030.01.00-py38", "stable-py38", "stable-py3"),
("2030.01.00-py38", "stable-py38", "stable-py38"),
("2030.01.00-py38", "stable-py38", "2030.01"),
("2030.01.00-py38", "stable-py38", "2030.01.00-py38"),
],
(f"bleeding-py38-rhel{rhel_version}", "bleeding-py38", "bleeding"),
(f"bleeding-py38-rhel{rhel_version}", "bleeding-py38", "bleeding-py3"),
(f"bleeding-py38-rhel{rhel_version}", "bleeding-py38", "bleeding-py38"),
]
return base_params


@pytest.mark.parametrize(
"expect, track_name,name",
generate_test_params_simple(rhel_version()),
)
def test_resolve_simple(komodo_root, track_name, name, expect):
release, tracked = main.resolve_release(komodo_root, name)
Expand Down Expand Up @@ -55,22 +60,24 @@ def test_resolve_fail_singular(komodo_root):
assert "--no-update" in str(exc.value)


@pytest.mark.parametrize(
"expect,name",
[
# Bleeding is py38, rhel7
("bleeding-py38-rhel7", "bleeding"),
("bleeding-py38-rhel7", "bleeding-py3"),
("bleeding-py38-rhel7", "bleeding-py38"),
# Stable is py38, unspecified rhel
def generate_test_params_no_update(rhel_version):
base_params = [
("2030.01.00-py38", "stable"),
("2030.01.00-py38", "stable-py3"),
("2030.01.00-py38", "stable-py38"),
("2030.01.00-py38", "2030.01"),
("2030.01.00-py38", "2030.01.00-py38"),
# Singular release
("2030.01.01-py38", "2030.01.01-py38"),
],
(f"bleeding-py38-rhel{rhel_version}", "bleeding"),
(f"bleeding-py38-rhel{rhel_version}", "bleeding-py3"),
(f"bleeding-py38-rhel{rhel_version}", "bleeding-py38"),
]
return base_params


@pytest.mark.parametrize(
"expect, name",
generate_test_params_no_update(rhel_version()),
)
def test_resolve_no_update(komodo_root, expect, name):
release, tracked = main.resolve_release(komodo_root, name, no_update=True)
Expand Down
11 changes: 6 additions & 5 deletions tests/test_update.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from komodoenv import update
from textwrap import dedent
from pkg_resources import get_distribution
import time
import os
import sys
import time
from importlib.metadata import distribution
from textwrap import dedent

from komodoenv import update


def test_rewrite_executable_python():
Expand Down Expand Up @@ -152,7 +153,7 @@ def test_get_pkg_version_exists():
"pip",
)

assert ver == get_distribution("pip").version
assert ver == distribution("pip").version


def test_get_pkg_version_none():
Expand Down

0 comments on commit f052b40

Please sign in to comment.