Support for python3.7 and python3.8
continuous-integration/drone/push Build is passing Details

Added tox targets as well
This commit is contained in:
IamTheFij 2022-06-30 13:46:04 -07:00
parent 1b74126494
commit 3f23ddd3cc
4 changed files with 31 additions and 22 deletions

View File

@ -2,6 +2,8 @@
This builder functions as a pseudo builder that instead downloads and installs a binary file using
release-gitter based on a pyproject.toml file. It's a total hack...
"""
from __future__ import annotations
from pathlib import Path
from shutil import copytree
from shutil import move

View File

@ -1,4 +1,6 @@
#! /usr/bin/env python3
from __future__ import annotations
import argparse
import platform
from collections.abc import Sequence
@ -91,7 +93,14 @@ def parse_git_remote(git_url: Optional[str] = None) -> GitRemoteInfo:
f"{path[1:3]} Could not parse owner and repo from URL {git_url}"
)
return GitRemoteInfo(u.hostname, path[1], path[2].removesuffix(".git"))
repo = path[2]
try:
repo = repo.removesuffix(".git") # type: ignore
except AttributeError:
# Py < 3.9
repo = repo[: -len(".git")] if repo and repo.endswith(".git") else repo
return GitRemoteInfo(u.hostname, path[1], repo)
def parse_cargo_version(p: Path) -> str:

View File

@ -1,3 +1,5 @@
from __future__ import annotations
import unittest
from pathlib import Path
from typing import Any
@ -111,27 +113,23 @@ class TestVersionInfo(unittest.TestCase):
version = release_gitter.read_version()
self.assertIsNone(version)
def test_cargo_file_has_version(self):
with (
patch("pathlib.Path.exists", return_value=True),
patch(
"pathlib.Path.open",
mock_open(read_data="\n".join(["[package]", 'version = "1.0.0"'])),
),
):
version = release_gitter.read_version()
self.assertEqual(version, "1.0.0")
@patch("pathlib.Path.exists", return_value=True)
@patch(
"pathlib.Path.open",
mock_open(read_data="\n".join(["[package]", 'version = "1.0.0"'])),
)
def test_cargo_file_has_version(self, *_):
version = release_gitter.read_version()
self.assertEqual(version, "1.0.0")
def test_cargo_file_missing_version(self):
with (
patch("pathlib.Path.exists", return_value=True),
patch(
"pathlib.Path.open",
mock_open(read_data="\n".join(["[package]"])),
),
):
with self.assertRaises(ValueError):
release_gitter.read_version()
@patch("pathlib.Path.exists", return_value=True)
@patch(
"pathlib.Path.open",
mock_open(read_data="\n".join(["[package]"])),
)
def test_cargo_file_missing_version(self, *_):
with self.assertRaises(ValueError):
release_gitter.read_version()
if __name__ == "__main__":

View File

@ -1,5 +1,5 @@
[tox]
envlist = py3
envlist = py3,py37,py38,py39
[testenv]
deps =