From bb0b82ab72aa0243aefe89c77301fc07e449a6cb Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Wed, 6 Nov 2024 16:13:58 -0800 Subject: [PATCH] Add itest for pseudobuilder --- pseudo_builder_test.py | 46 ++++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 pseudo_builder_test.py diff --git a/pseudo_builder_test.py b/pseudo_builder_test.py new file mode 100644 index 0000000..48046ad --- /dev/null +++ b/pseudo_builder_test.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +import shutil +import subprocess +import venv +from pathlib import Path +from unittest import TestCase + +ITEST_VENV_PATH = Path("venv-itest") + + +class TestPseudoBuilder(TestCase): + def setUp(self): + venv.create( + ITEST_VENV_PATH, + system_site_packages=False, + clear=True, + with_pip=True, + ) + self.pip_install("-e", ".[builder]") + + def tearDown(self): + shutil.rmtree(ITEST_VENV_PATH) + + def pip_install(self, *args: str): + subprocess.run( + [str(ITEST_VENV_PATH.joinpath("bin", "pip")), "install", *args], + check=True, + ) + + def test_install_remote_package(self): + self.assertTrue(ITEST_VENV_PATH.exists()) + self.assertTrue(ITEST_VENV_PATH.joinpath("bin", "python").exists()) + self.assertTrue(ITEST_VENV_PATH.joinpath("bin", "pip").exists()) + + itest_packages = { + "stylua": "git+https://github.com/JohnnyMorganz/StyLua", + "selene": "git+https://github.com/amitds1997/selene", + } + + for package, source in itest_packages.items(): + self.pip_install("--no-index", "--no-build-isolation", source) + # Check if the package is installed + assert ITEST_VENV_PATH.joinpath("bin", package).exists() + # Check if the package has executable permissions + assert ITEST_VENV_PATH.joinpath("bin", package).stat().st_mode & 0o111 diff --git a/pyproject.toml b/pyproject.toml index 96b99a5..0eaa4df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ dependencies = [ [tool.hatch.envs.test.scripts] run = [ "coverage erase", - "coverage run --source=release_gitter -m unittest discover . *_test.py", + "coverage run --source=release_gitter -m unittest discover -p '*_test.py'", "coverage report -m # --fail-under 70", ]