Support for python3.7 and python3.8
All checks were successful
continuous-integration/drone/push Build is passing

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 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... release-gitter based on a pyproject.toml file. It's a total hack...
""" """
from __future__ import annotations
from pathlib import Path from pathlib import Path
from shutil import copytree from shutil import copytree
from shutil import move from shutil import move

View File

@ -1,4 +1,6 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
from __future__ import annotations
import argparse import argparse
import platform import platform
from collections.abc import Sequence 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}" 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: def parse_cargo_version(p: Path) -> str:

View File

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

View File

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