Skip to content

Commit

Permalink
Fix build by updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
monim67 committed Sep 14, 2022
1 parent 02e302a commit fbc9ac3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 25 deletions.
20 changes: 19 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "poetry-bumpversion"
version = "0.0.0"
description = "Poetry plugin to update project version strings on poetry version command"
authors = ["Abdul Monim <abdul.monim@graaho.com>"]
authors = ["Munim Munna <[email protected].com>"]
readme = "README.rst"
packages = [{ include = "poetry_bumpversion" }]
repository = "https://github.com/monim67/poetry-bumpversion"
Expand All @@ -15,6 +15,7 @@ poetry = "^1.2.0a1"

[tool.poetry.group.build.dependencies]
black = "^22.3.0"
isort = "^5.10.1"
pytest = "^7.1.3"
rstcheck = "^6.0.0.post1"
poethepoet = "^0.15.0"
Expand Down Expand Up @@ -46,17 +47,17 @@ isolated_build = True
envlist = py{310,39,38,37}
[testenv]
whitelist_externals = poetry
skip_install = true
commands =
poe lint
pytest
allowlist_externals =
poe
pytest
poetry install --only main,build
poetry run poe lint
poetry run pytest
"""

[tool.poe.tasks.lint]
shell = """
python -m black --check poetry_bumpversion tests
python -m isort --check-only poetry_bumpversion tests
rstcheck --report-level warning *.rst
"""
[tool.poe.tasks]
lint = [
{ cmd = "python -m black --check poetry_bumpversion tests" },
{ cmd = "python -m isort --check-only poetry_bumpversion tests" },
{ cmd = "rstcheck --report-level warning *.rst" },
]
24 changes: 12 additions & 12 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
testing_assets = Path(__file__).parent / "assets"


def copy_project(project_name: str, destination_dir: Path):
def copy_project(project_name: str, destination_dir: Path) -> Path:
package_path = testing_assets / project_name
shutil.copytree(package_path, destination_dir, dirs_exist_ok=True)
return shutil.copytree(package_path, destination_dir / "project")


def execute_update_version_command(project_dir: Path, new_version: str):
Expand All @@ -25,25 +25,25 @@ def execute_update_version_command(project_dir: Path, new_version: str):

def test_project_with_instructions(tmp_path: Path):
new_version = "1.0.0"
copy_project("project_with_instructions", tmp_path)
result = execute_update_version_command(tmp_path, new_version)
project_dir = copy_project("project_with_instructions", tmp_path)
result = execute_update_version_command(project_dir, new_version)
assert new_version in result.stdout
for file in (
tmp_path / "test_package/__init__.py",
tmp_path / "test_package/version.py",
tmp_path / "README.md",
project_dir / "test_package/__init__.py",
project_dir / "test_package/version.py",
project_dir / "README.md",
):
assert new_version in file.read_text()


def test_project_with_replacements(tmp_path: Path):
new_version = "1.0.0"
copy_project("project_with_replacements", tmp_path)
result = execute_update_version_command(tmp_path, new_version)
project_dir = copy_project("project_with_replacements", tmp_path)
result = execute_update_version_command(project_dir, new_version)
assert new_version in result.stdout
for file in (
tmp_path / "test_package/__init__.py",
tmp_path / "test_package/version.py",
tmp_path / "README.md",
project_dir / "test_package/__init__.py",
project_dir / "test_package/version.py",
project_dir / "README.md",
):
assert new_version in file.read_text()

0 comments on commit fbc9ac3

Please sign in to comment.