Skip to content

Commit

Permalink
refactor: move package managers into a package
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Jan 26, 2024
1 parent 6e86941 commit 8230581
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/onepm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from packaging.requirements import Requirement
from packaging.utils import canonicalize_name

from onepm.base import PackageManager
from onepm.pdm import PDM
from onepm.pip import Pip
from onepm.pipenv import Pipenv
from onepm.poetry import Poetry
from onepm.pm.base import PackageManager
from onepm.pm.pdm import PDM
from onepm.pm.pip import Pip
from onepm.pm.pipenv import Pipenv
from onepm.pm.poetry import Poetry

if sys.version_info >= (3, 11):
import tomllib
Expand Down
Empty file added src/onepm/pm/__init__.py
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/onepm/pdm.py → src/onepm/pm/pdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from typing import Any, NoReturn

from onepm.base import PackageManager
from onepm.pm.base import PackageManager


class PDM(PackageManager):
Expand Down
2 changes: 1 addition & 1 deletion src/onepm/pip.py → src/onepm/pm/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
from typing import Any, NoReturn

from onepm.base import PackageManager
from onepm.pm.base import PackageManager


class Pip(PackageManager):
Expand Down
2 changes: 1 addition & 1 deletion src/onepm/pipenv.py → src/onepm/pm/pipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from typing import Any, NoReturn

from onepm.base import PackageManager
from onepm.pm.base import PackageManager


class Pipenv(PackageManager):
Expand Down
2 changes: 1 addition & 1 deletion src/onepm/poetry.py → src/onepm/pm/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from typing import Any, NoReturn

from onepm.base import PackageManager
from onepm.pm.base import PackageManager


class Poetry(PackageManager):
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def execute_args(monkeypatch):
def fake_execute(args):
call_args[:] = args

monkeypatch.setattr("onepm.base.PackageManager._execute_command", fake_execute)
monkeypatch.setattr("onepm.pm.base.PackageManager._execute_command", fake_execute)
return call_args


Expand All @@ -39,7 +39,7 @@ def poetry(monkeypatch):
"onepm.determine_package_manager", mock.Mock(return_value=Poetry)
)
monkeypatch.setattr(
"onepm.base.PackageManager.find_executable", mock.Mock(return_value="poetry")
"onepm.pm.base.PackageManager.find_executable", mock.Mock(return_value="poetry")
)


Expand All @@ -49,13 +49,13 @@ def pipenv(monkeypatch):
"onepm.determine_package_manager", mock.Mock(return_value=Pipenv)
)
monkeypatch.setattr(
"onepm.base.PackageManager.find_executable", mock.Mock(return_value="pipenv")
"onepm.pm.base.PackageManager.find_executable", mock.Mock(return_value="pipenv")
)


@pytest.fixture()
def pdm(monkeypatch):
monkeypatch.setattr("onepm.determine_package_manager", mock.Mock(return_value=PDM))
monkeypatch.setattr(
"onepm.base.PackageManager.find_executable", mock.Mock(return_value="pdm")
"onepm.pm.base.PackageManager.find_executable", mock.Mock(return_value="pdm")
)
5 changes: 2 additions & 3 deletions tests/test_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import pytest

from onepm import pa, pi, pr, pu, pun
from onepm.pip import Pip
from onepm import Pip, pa, pi, pr, pu, pun

pytestmark = pytest.mark.usefixtures("pip")

Expand All @@ -17,7 +16,7 @@ def mock_find_executable(name: str, path: str | None = None) -> str:

monkeypatch.setenv("VIRTUAL_ENV", "foo")
monkeypatch.setattr(
"onepm.base.PackageManager.find_executable", mock_find_executable
"onepm.pm.base.PackageManager.find_executable", mock_find_executable
)


Expand Down

0 comments on commit 8230581

Please sign in to comment.