Skip to content

Commit

Permalink
Remove: Drop VersionCalculator from VersionCommands
Browse files Browse the repository at this point in the history
The VersionCalculator can be acquired via a Project instance now.
  • Loading branch information
bjoernricks committed Mar 2, 2023
1 parent eeed85f commit b8982d6
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 39 deletions.
6 changes: 1 addition & 5 deletions pontos/version/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from typing import Literal, Type, Union
from typing import Literal, Union

from packaging.version import InvalidVersion
from packaging.version import Version as PackagingVersion
Expand Down Expand Up @@ -223,7 +223,6 @@ class VersionCommand(ABC):
version commands for several programming languages"""

project_file_name: str
version_calculator_class: Type[VersionCalculator] = VersionCalculator

def __init__(self) -> None:
self.project_file_path = Path.cwd() / self.project_file_name
Expand All @@ -249,6 +248,3 @@ def project_found(self) -> bool:
Returns True if a command has detected a corresponding project
"""
return self.project_file_path.exists()

def get_version_calculator(self) -> VersionCalculator:
return self.version_calculator_class()
9 changes: 1 addition & 8 deletions tests/version/test_cmake_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@
from pontos.testing import temp_directory, temp_file
from pontos.version.cmake import CMakeVersionCommand, CMakeVersionParser
from pontos.version.errors import VersionError
from pontos.version.version import Version, VersionCalculator


class CMakeVersionCommandTestCase(unittest.TestCase):
def test_get_version_calculator(self):
cmake = CMakeVersionCommand()

self.assertIsInstance(cmake.get_version_calculator(), VersionCalculator)
from pontos.version.version import Version


class VerifyCMakeVersionCommandTestCase(unittest.TestCase):
Expand Down
9 changes: 1 addition & 8 deletions tests/version/test_go_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pontos.testing import temp_directory, temp_file
from pontos.version.errors import VersionError
from pontos.version.go import GoVersionCommand
from pontos.version.version import Version, VersionCalculator
from pontos.version.version import Version


@dataclass
Expand All @@ -42,13 +42,6 @@ class StdOutput:
\n"""


class GoVersionCommandTestCase(unittest.TestCase):
def test_get_version_calculator(self):
go = GoVersionCommand()

self.assertIsInstance(go.get_version_calculator(), VersionCalculator)


class GetCurrentGoVersionCommandTestCase(unittest.TestCase):
def test_getting_version(self):
with temp_file(
Expand Down
9 changes: 1 addition & 8 deletions tests/version/test_javascript_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@
from pontos.testing import temp_directory, temp_file
from pontos.version.errors import VersionError
from pontos.version.javascript import JavaScriptVersionCommand
from pontos.version.version import Version, VersionCalculator


class JavaScriptVersionCommandTestCase(unittest.TestCase):
def test_get_version_calculator(self):
js = JavaScriptVersionCommand()

self.assertIsInstance(js.get_version_calculator(), VersionCalculator)
from pontos.version.version import Version


class GetCurrentJavaScriptVersionCommandTestCase(unittest.TestCase):
Expand Down
11 changes: 1 addition & 10 deletions tests/version/test_python_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,7 @@
from pontos.testing import temp_directory, temp_file, temp_python_module
from pontos.version.errors import VersionError
from pontos.version.python import PythonVersionCommand
from pontos.version.version import Version, VersionCalculator


class PythonVersionCommandTestCase(unittest.TestCase):
def test_get_version_calculator(self):
python = PythonVersionCommand()

self.assertIsInstance(
python.get_version_calculator(), VersionCalculator
)
from pontos.version.version import Version


class GetCurrentPythonVersionCommandTestCase(unittest.TestCase):
Expand Down

0 comments on commit b8982d6

Please sign in to comment.