diff --git a/conftest.py b/conftest.py index e1a88343..eade178a 100644 --- a/conftest.py +++ b/conftest.py @@ -42,4 +42,3 @@ def setup( set_home: pathlib.Path, ) -> None: """Configure test fixtures for pytest.""" - pass diff --git a/docs/conf.py b/docs/conf.py index daebf5ee..a594c985 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -209,15 +209,14 @@ def linkcode_resolve(domain: str, info: dict[str, str]) -> t.Union[None, str]: fn, linespec, ) - else: - return "{}/blob/v{}/{}/{}/{}{}".format( - about["__github__"], - about["__version__"], - "src", - about["__package_name__"], - fn, - linespec, - ) + return "{}/blob/v{}/{}/{}/{}{}".format( + about["__github__"], + about["__version__"], + "src", + about["__package_name__"], + fn, + linespec, + ) def remove_tabs_js(app: "Sphinx", exc: Exception) -> None: diff --git a/src/libvcs/__init__.py b/src/libvcs/__init__.py index fe0d6486..8c936ed6 100644 --- a/src/libvcs/__init__.py +++ b/src/libvcs/__init__.py @@ -9,11 +9,11 @@ from .sync.svn import SvnSync __all__ = [ + "BaseSync", + "CmdLoggingAdapter", "GitSync", "HgSync", "SvnSync", - "BaseSync", - "CmdLoggingAdapter", ] logger = logging.getLogger(__name__) diff --git a/src/libvcs/_internal/query_list.py b/src/libvcs/_internal/query_list.py index ef93c9ef..f791bbc1 100644 --- a/src/libvcs/_internal/query_list.py +++ b/src/libvcs/_internal/query_list.py @@ -84,9 +84,8 @@ def keygetter( dct = dct[sub_field] elif hasattr(dct, sub_field): dct = getattr(dct, sub_field) - except Exception as e: + except Exception: traceback.print_stack() - print(f"Above error was {e}") return None return dct @@ -304,12 +303,12 @@ def lookup_iregex( class PKRequiredException(Exception): - def __init__(self, *args: object): + def __init__(self, *args: object) -> None: return super().__init__("items() require a pk_key exists") class OpNotFound(ValueError): - def __init__(self, op: str, *args: object): + def __init__(self, op: str, *args: object) -> None: return super().__init__(f"{op} not in LOOKUP_NAME_MAP") @@ -470,7 +469,7 @@ def __init__(self, items: t.Optional["Iterable[T]"] = None) -> None: def items(self) -> list[tuple[str, T]]: if self.pk_key is None: - raise PKRequiredException() + raise PKRequiredException return [(getattr(item, self.pk_key), item) for item in self] def __eq__( @@ -490,9 +489,8 @@ def __eq__( for key in a_keys: if abs(a[key] - b[key]) > 1: return False - else: - if a != b: - return False + elif a != b: + return False return True return False @@ -529,8 +527,7 @@ def filter_lookup(obj: t.Any) -> bool: def val_match(obj: t.Union[str, list[t.Any], T]) -> bool: if isinstance(matcher, list): return obj in matcher - else: - return bool(obj == matcher) + return bool(obj == matcher) _filter = val_match else: @@ -546,9 +543,9 @@ def get( ) -> t.Optional[T]: objs = self.filter(matcher=matcher, **kwargs) if len(objs) > 1: - raise MultipleObjectsReturned() - elif len(objs) == 0: + raise MultipleObjectsReturned + if len(objs) == 0: if default == no_arg: - raise ObjectDoesNotExist() + raise ObjectDoesNotExist return default return objs[0] diff --git a/src/libvcs/_internal/run.py b/src/libvcs/_internal/run.py index 12e44588..e5e6b07c 100644 --- a/src/libvcs/_internal/run.py +++ b/src/libvcs/_internal/run.py @@ -15,10 +15,9 @@ from collections.abc import Iterable, Mapping, MutableMapping, Sequence from typing import IO, TYPE_CHECKING, Any, AnyStr, Callable, Optional, Protocol, Union +from libvcs import exc from libvcs._internal.types import StrOrBytesPath -from .. import exc - logger = logging.getLogger(__name__) console_encoding = sys.__stdout__.encoding diff --git a/src/libvcs/_internal/shortcuts.py b/src/libvcs/_internal/shortcuts.py index 6f816fa1..ce5634b4 100644 --- a/src/libvcs/_internal/shortcuts.py +++ b/src/libvcs/_internal/shortcuts.py @@ -19,17 +19,17 @@ class VCSNoMatchFoundForUrl(exc.LibVCSException): - def __init__(self, url: str, *args: object): + def __init__(self, url: str, *args: object) -> None: return super().__init__(f"No VCS found for url: {url}") class VCSMultipleMatchFoundForUrl(exc.LibVCSException): - def __init__(self, url: str, *args: object): + def __init__(self, url: str, *args: object) -> None: return super().__init__(f"Multiple VCS found for url: {url}") class VCSNotSupported(exc.LibVCSException): - def __init__(self, url: str, vcs: str, *args: object): + def __init__(self, url: str, vcs: str, *args: object) -> None: return super().__init__(f"VCS '{vcs}' not supported, based on URL: {url}") @@ -110,7 +110,7 @@ def create_project( assert vcs_matches[0].vcs is not None def is_vcs(val: t.Any) -> "TypeGuard[VCSLiteral]": - return isinstance(val, str) and val in ["git", "hg", "svn"] + return isinstance(val, str) and val in {"git", "hg", "svn"} if is_vcs(vcs_matches[0].vcs): vcs = vcs_matches[0].vcs @@ -119,13 +119,18 @@ def is_vcs(val: t.Any) -> "TypeGuard[VCSLiteral]": if vcs == "git": return GitSync( - url=url, path=path, progress_callback=progress_callback, **kwargs + url=url, + path=path, + progress_callback=progress_callback, + **kwargs, ) - elif vcs == "hg": + if vcs == "hg": return HgSync(url=url, path=path, progress_callback=progress_callback, **kwargs) - elif vcs == "svn": + if vcs == "svn": return SvnSync( - url=url, path=path, progress_callback=progress_callback, **kwargs + url=url, + path=path, + progress_callback=progress_callback, + **kwargs, ) - else: - raise InvalidVCS("VCS %s is not a valid VCS" % vcs) + raise InvalidVCS("VCS %s is not a valid VCS" % vcs) diff --git a/src/libvcs/_internal/subprocess.py b/src/libvcs/_internal/subprocess.py index 576e1ea1..34b72de5 100644 --- a/src/libvcs/_internal/subprocess.py +++ b/src/libvcs/_internal/subprocess.py @@ -67,7 +67,7 @@ class SubprocessCheckOutputError(Exception): - def __init__(self, output: str, *args: object): + def __init__(self, output: str, *args: object) -> None: return super().__init__(f"output is not str or bytes: {output}") diff --git a/src/libvcs/cmd/git.py b/src/libvcs/cmd/git.py index 889bef26..2f4c0e3d 100644 --- a/src/libvcs/cmd/git.py +++ b/src/libvcs/cmd/git.py @@ -206,7 +206,7 @@ def run( def stringify(v: Any) -> str: if isinstance(v, bool): return "true" if True else "false" - elif not isinstance(v, str): + if not isinstance(v, str): return str(v) return v @@ -398,7 +398,6 @@ def fetch( Union[bool, Literal["yes", "on-demand"]] ] = None, submodule_prefix: Optional[StrOrBytesPath] = None, - # _all: Optional[bool] = None, force: Optional[bool] = None, keep: Optional[bool] = None, @@ -1821,9 +1820,8 @@ def rev_parse( if parseopt is True: if args is not None: local_flags.extend(["--", args]) - else: - if args is not None: - local_flags.append(args) + elif args is not None: + local_flags.append(args) return self.run( ["rev-parse", *local_flags], diff --git a/src/libvcs/cmd/svn.py b/src/libvcs/cmd/svn.py index 3f83c72d..2101582b 100644 --- a/src/libvcs/cmd/svn.py +++ b/src/libvcs/cmd/svn.py @@ -25,7 +25,7 @@ class SvnPropsetValueOrValuePathRequired(exc.LibVCSException, TypeError): """Raised when required parameters are not passed.""" - def __init__(self, *args: object): + def __init__(self, *args: object) -> None: return super().__init__("Must enter a value or value_path") @@ -783,7 +783,7 @@ def propset( elif isinstance(value_path, pathlib.Path): local_flags.extend(["--file", str(pathlib.Path(value_path).absolute())]) else: - raise SvnPropsetValueOrValuePathRequired() + raise SvnPropsetValueOrValuePathRequired if path is not None: if isinstance(path, (str, pathlib.Path)): diff --git a/src/libvcs/pytest_plugin.py b/src/libvcs/pytest_plugin.py index 7c47766a..30ae3f51 100644 --- a/src/libvcs/pytest_plugin.py +++ b/src/libvcs/pytest_plugin.py @@ -23,7 +23,7 @@ class MaxUniqueRepoAttemptsExceeded(exc.LibVCSException): """Raised when exceeded threshold of attempts to find a unique repo destination.""" - def __init__(self, attempts: int, *args: object): + def __init__(self, attempts: int, *args: object) -> None: """Raise LibVCSException exception with message including attempts tried.""" return super().__init__( f"Could not find unused repo destination (attempts: {attempts})", @@ -73,12 +73,10 @@ def pytest_ignore_collect(collection_path: pathlib.Path, config: pytest.Config) return True if not shutil.which("git") and "git" in str(collection_path): return True - if not shutil.which("hg") and any( - needle in str(collection_path) for needle in ["hg", "mercurial"] - ): - return True - - return False + return bool( + not shutil.which("hg") + and any(needle in str(collection_path) for needle in ["hg", "mercurial"]) + ) @pytest.fixture(scope="session") @@ -101,7 +99,7 @@ def user_path(home_path: pathlib.Path, home_user_name: str) -> pathlib.Path: return p -@pytest.fixture(scope="function") +@pytest.fixture() def set_home( monkeypatch: pytest.MonkeyPatch, user_path: pathlib.Path, @@ -110,7 +108,7 @@ def set_home( monkeypatch.setenv("HOME", str(user_path)) -@pytest.fixture +@pytest.fixture() @skip_if_git_missing def gitconfig(user_path: pathlib.Path, set_home: pathlib.Path) -> pathlib.Path: """Return git configuration, pytest fixture.""" @@ -145,7 +143,7 @@ def gitconfig(user_path: pathlib.Path, set_home: pathlib.Path) -> pathlib.Path: return gitconfig -@pytest.fixture +@pytest.fixture() @skip_if_hg_missing def hgconfig(user_path: pathlib.Path, set_home: pathlib.Path) -> pathlib.Path: """Return Mercurial configuration, pytest fixture.""" @@ -166,7 +164,7 @@ def hgconfig(user_path: pathlib.Path, set_home: pathlib.Path) -> pathlib.Path: return hgrc -@pytest.fixture(scope="function") +@pytest.fixture() def projects_path( user_path: pathlib.Path, request: pytest.FixtureRequest, @@ -182,7 +180,7 @@ def clean() -> None: return path -@pytest.fixture(scope="function") +@pytest.fixture() def remote_repos_path( user_path: pathlib.Path, request: pytest.FixtureRequest, @@ -257,7 +255,7 @@ def _create_git_remote_repo( return remote_repo_path -@pytest.fixture +@pytest.fixture() @skip_if_git_missing def create_git_remote_repo( remote_repos_path: pathlib.Path, @@ -290,8 +288,7 @@ def git_remote_repo_single_commit_post_init(remote_repo_path: pathlib.Path) -> N run(["git", "commit", "-m", "test file for dummyrepo"], cwd=remote_repo_path) -@pytest.fixture -@pytest.mark.usefixtures("gitconfig", "set_home") +@pytest.fixture() @skip_if_git_missing def git_remote_repo(remote_repos_path: pathlib.Path) -> pathlib.Path: """Pre-made git repo w/ 1 commit, used as a file:// remote to clone and push to.""" @@ -343,7 +340,7 @@ def svn_remote_repo_single_commit_post_init(remote_repo_path: pathlib.Path) -> N ) -@pytest.fixture +@pytest.fixture() @skip_if_svn_missing def create_svn_remote_repo( remote_repos_path: pathlib.Path, @@ -368,18 +365,16 @@ def fn( return fn -@pytest.fixture +@pytest.fixture() @skip_if_svn_missing def svn_remote_repo(remote_repos_path: pathlib.Path) -> pathlib.Path: """Pre-made. Local file:// based SVN server.""" - remote_repo_path = _create_svn_remote_repo( + return _create_svn_remote_repo( remote_repos_path=remote_repos_path, remote_repo_name="svn_server_dir", remote_repo_post_init=None, ) - return remote_repo_path - def _create_hg_remote_repo( remote_repos_path: pathlib.Path, @@ -408,7 +403,7 @@ def hg_remote_repo_single_commit_post_init(remote_repo_path: pathlib.Path) -> No run(["hg", "commit", "-m", "test file for hg repo"], cwd=remote_repo_path) -@pytest.fixture +@pytest.fixture() @skip_if_hg_missing def create_hg_remote_repo( remote_repos_path: pathlib.Path, @@ -435,7 +430,7 @@ def fn( return fn -@pytest.fixture +@pytest.fixture() @skip_if_hg_missing def hg_remote_repo( remote_repos_path: pathlib.Path, @@ -449,7 +444,7 @@ def hg_remote_repo( ) -@pytest.fixture +@pytest.fixture() def git_repo(projects_path: pathlib.Path, git_remote_repo: pathlib.Path) -> GitSync: """Pre-made git clone of remote repo checked out to user's projects dir.""" git_repo = GitSync( @@ -467,7 +462,7 @@ def git_repo(projects_path: pathlib.Path, git_remote_repo: pathlib.Path) -> GitS return git_repo -@pytest.fixture +@pytest.fixture() def hg_repo(projects_path: pathlib.Path, hg_remote_repo: pathlib.Path) -> HgSync: """Pre-made hg clone of remote repo checked out to user's projects dir.""" hg_repo = HgSync( @@ -478,7 +473,7 @@ def hg_repo(projects_path: pathlib.Path, hg_remote_repo: pathlib.Path) -> HgSync return hg_repo -@pytest.fixture +@pytest.fixture() def svn_repo(projects_path: pathlib.Path, svn_remote_repo: pathlib.Path) -> SvnSync: """Pre-made svn clone of remote repo checked out to user's projects dir.""" svn_repo = SvnSync( @@ -489,7 +484,7 @@ def svn_repo(projects_path: pathlib.Path, svn_remote_repo: pathlib.Path) -> SvnS return svn_repo -@pytest.fixture +@pytest.fixture() def add_doctest_fixtures( request: pytest.FixtureRequest, doctest_namespace: dict[str, Any], diff --git a/src/libvcs/sync/base.py b/src/libvcs/sync/base.py index 6e581206..1d2e8c48 100644 --- a/src/libvcs/sync/base.py +++ b/src/libvcs/sync/base.py @@ -28,7 +28,7 @@ def convert_pip_url(pip_url: str) -> VCSLocation: ) assert "+" in pip_url, error_message % pip_url url = pip_url.split("+", 1)[1] - scheme, netloc, path, query, frag = urlparse.urlsplit(url) + scheme, netloc, path, query, _frag = urlparse.urlsplit(url) rev = None if "@" in path: path, rev = path.rsplit("@", 1) @@ -134,9 +134,7 @@ def repo_name(self) -> str: def from_pip_url(cls, pip_url: str, **kwargs: Any) -> "BaseSync": """Create synchronization object from pip-style URL.""" url, rev = convert_pip_url(pip_url) - self = cls(url=url, rev=rev, **kwargs) - - return self + return cls(url=url, rev=rev, **kwargs) def run( self, diff --git a/src/libvcs/sync/git.py b/src/libvcs/sync/git.py index 73e464bc..f879c271 100644 --- a/src/libvcs/sync/git.py +++ b/src/libvcs/sync/git.py @@ -22,6 +22,7 @@ from typing import Any, Optional, Union from urllib import parse as urlparse +from libvcs import exc from libvcs._internal.types import StrPath from libvcs.cmd.git import Git from libvcs.sync.base import ( @@ -30,15 +31,13 @@ convert_pip_url as base_convert_pip_url, ) -from .. import exc - logger = logging.getLogger(__name__) class GitStatusParsingException(exc.LibVCSException): """Raised when git status output is not in the expected format.""" - def __init__(self, git_status_output: str, *args: object): + def __init__(self, git_status_output: str, *args: object) -> None: return super().__init__( "Could not find match for git-status(1)" + f"Output: {git_status_output}", ) @@ -47,28 +46,28 @@ def __init__(self, git_status_output: str, *args: object): class GitRemoteOriginMissing(exc.LibVCSException): """Raised when git origin remote was not found.""" - def __init__(self, remotes: list[str], *args: object): + def __init__(self, remotes: list[str], *args: object) -> None: return super().__init__(f"Missing origin. Remotes: {', '.join(remotes)}") class GitRemoteSetError(exc.LibVCSException): """Raised when a git remote could not be set.""" - def __init__(self, remote_name: str): + def __init__(self, remote_name: str) -> None: return super().__init__(f"Remote {remote_name} not found after setting") class GitNoBranchFound(exc.LibVCSException): """Raised with git branch could not be found.""" - def __init__(self, *args: object): + def __init__(self, *args: object) -> None: return super().__init__("No branch found for git repository") class GitRemoteRefNotFound(exc.CommandError): """Raised when a git remote ref (tag, branch) could not be found.""" - def __init__(self, git_tag: str, ref_output: str, *args: object): + def __init__(self, git_tag: str, ref_output: str, *args: object) -> None: return super().__init__( f"Could not fetch remote in refs/remotes/{git_tag}:" + f"Output: {ref_output}", @@ -271,11 +270,9 @@ def __init__( ) elif isinstance(remote_url, dict): self._remotes[remote_name] = GitRemote( - **{ - "fetch_url": remote_url["fetch_url"], - "push_url": remote_url["push_url"], - "name": remote_name, - }, + fetch_url=remote_url["fetch_url"], + push_url=remote_url["push_url"], + name=remote_name, ) elif isinstance(remote_url, GitRemote): self._remotes[remote_name] = remote_url @@ -303,9 +300,7 @@ def __init__( def from_pip_url(cls, pip_url: str, **kwargs: Any) -> "GitSync": """Clone a git repository from a pip-style URL.""" url, rev = convert_pip_url(pip_url) - self = cls(url=url, rev=rev, **kwargs) - - return self + return cls(url=url, rev=rev, **kwargs) def get_revision(self) -> str: """Return current revision. Initial repositories return 'initial'.""" @@ -342,16 +337,15 @@ def set_remotes(self, overwrite: bool = False) -> None: push=True, overwrite=overwrite, ) - else: - if ( - not existing_remote - or existing_remote.fetch_url != git_remote_repo.fetch_url - ): - self.set_remote( - name=remote_name, - url=git_remote_repo.fetch_url, - overwrite=overwrite, - ) + elif ( + not existing_remote + or existing_remote.fetch_url != git_remote_repo.fetch_url + ): + self.set_remote( + name=remote_name, + url=git_remote_repo.fetch_url, + overwrite=overwrite, + ) def obtain(self, *args: Any, **kwargs: Any) -> None: """Retrieve the repository, clone if doesn't exist.""" @@ -584,7 +578,7 @@ def remote(self, name: str, **kwargs: Any) -> Optional[GitRemote]: lines = ret.split("\n") remote_fetch_url = lines[1].replace("Fetch URL: ", "").strip() remote_push_url = lines[2].replace("Push URL: ", "").strip() - if remote_fetch_url != name and remote_push_url != name: + if name not in {remote_fetch_url, remote_push_url}: return GitRemote( name=name, fetch_url=remote_fetch_url, @@ -638,7 +632,7 @@ def chomp_protocol(url: str) -> str: """ if "+" in url: url = url.split("+", 1)[1] - scheme, netloc, path, query, frag = urlparse.urlsplit(url) + scheme, netloc, path, query, _frag = urlparse.urlsplit(url) url = urlparse.urlunsplit((scheme, netloc, path, query, "")) if url.startswith("ssh://git@github.com/"): url = url.replace("ssh://", "git+ssh://") @@ -704,7 +698,7 @@ def get_current_remote_name(self) -> str: if match.branch_upstream is None: # no upstream set if match.branch_head is None: - raise GitNoBranchFound() + raise GitNoBranchFound return match.branch_head if match.branch_head is None: return match.branch_upstream diff --git a/src/libvcs/sync/svn.py b/src/libvcs/sync/svn.py index 62d72406..48b71c13 100644 --- a/src/libvcs/sync/svn.py +++ b/src/libvcs/sync/svn.py @@ -30,7 +30,7 @@ class SvnUrlRevFormattingError(ValueError): """Raised when SVN Revision output is not in the expected format.""" - def __init__(self, data: str, *args: object): + def __init__(self, data: str, *args: object) -> None: return super().__init__(f"Badly formatted data: {data!r}") @@ -104,7 +104,7 @@ def get_revision_file(self, location: str) -> int: """Return revision for a file.""" current_rev = self.cmd.info(location) - _INI_RE = re.compile(r"^([^:]+):\s+(\S.*)$", re.M) + _INI_RE = re.compile(r"^([^:]+):\s+(\S.*)$", re.MULTILINE) info_list = _INI_RE.findall(current_rev) return int(dict(info_list)["Revision"]) @@ -178,7 +178,7 @@ def _get_svn_url_rev(cls, location: str) -> tuple[Optional[str], int]: data = "" url = None - if data.startswith("8") or data.startswith("9") or data.startswith("10"): + if data.startswith(("8", "9", "10")): entries = list(map(str.splitlines, data.split("\n\x0c\n"))) del entries[0][0] # get rid of the '8' url = entries[0][3] diff --git a/src/libvcs/url/base.py b/src/libvcs/url/base.py index 1f533b02..be38621b 100644 --- a/src/libvcs/url/base.py +++ b/src/libvcs/url/base.py @@ -14,7 +14,7 @@ class URLProtocol(Protocol): """Common interface for VCS URL Parsers.""" - def __init__(self, url: str): ... + def __init__(self, url: str) -> None: ... def to_url(self) -> str: """Output to a command friendly URL for VCS.""" diff --git a/src/libvcs/url/registry.py b/src/libvcs/url/registry.py index 3023677b..eaa37548 100644 --- a/src/libvcs/url/registry.py +++ b/src/libvcs/url/registry.py @@ -33,7 +33,7 @@ class VCSRegistry: parser_map: t.ClassVar["ParserMap"] = {} - def __init__(self, parsers: "ParserLazyMap"): + def __init__(self, parsers: "ParserLazyMap") -> None: for k, v in parsers.items(): if isinstance(v, str): v = import_string(v) diff --git a/src/libvcs/url/svn.py b/src/libvcs/url/svn.py index 19c5da53..1a80df31 100644 --- a/src/libvcs/url/svn.py +++ b/src/libvcs/url/svn.py @@ -183,8 +183,6 @@ class SvnBaseURL(URLProtocol, SkipDefaultFieldsReprMixin): separator: str = dataclasses.field(default="/") path: str = dataclasses.field(default="") - # - # ref: Optional[str] = None rule: Optional[str] = None diff --git a/tests/_internal/subprocess/test_SubprocessCommand.py b/tests/_internal/subprocess/test_SubprocessCommand.py index 492b19a5..861e8c24 100644 --- a/tests/_internal/subprocess/test_SubprocessCommand.py +++ b/tests/_internal/subprocess/test_SubprocessCommand.py @@ -20,18 +20,18 @@ def idfn(val: Any) -> str: @pytest.mark.parametrize( - "args,kwargs,expected_result", + ("args", "kwargs", "expected_result"), [ - [["ls"], {}, SubprocessCommand("ls")], - [[["ls", "-l"]], {}, SubprocessCommand(["ls", "-l"])], - [[], {"args": ["ls", "-l"]}, SubprocessCommand(["ls", "-l"])], - [["ls -l"], {"shell": True}, SubprocessCommand("ls -l", shell=True)], - [[], {"args": "ls -l", "shell": True}, SubprocessCommand("ls -l", shell=True)], - [ + (["ls"], {}, SubprocessCommand("ls")), + ([["ls", "-l"]], {}, SubprocessCommand(["ls", "-l"])), + ([], {"args": ["ls", "-l"]}, SubprocessCommand(["ls", "-l"])), + (["ls -l"], {"shell": True}, SubprocessCommand("ls -l", shell=True)), + ([], {"args": "ls -l", "shell": True}, SubprocessCommand("ls -l", shell=True)), + ( [], {"args": ["ls", "-l"], "shell": True}, SubprocessCommand(["ls", "-l"], shell=True), - ], + ), ], ids=idfn, ) @@ -56,7 +56,7 @@ def test_init(args: list[Any], kwargs: dict[str, Any], expected_result: Any) -> @pytest.mark.parametrize( - "args,kwargs,expected_result", + ("args", "kwargs", "expected_result"), FIXTURES, ids=idfn, ) @@ -79,7 +79,7 @@ def test_init_and_Popen( @pytest.mark.parametrize( - "args,kwargs,expected_result", + ("args", "kwargs", "expected_result"), FIXTURES, ids=idfn, ) @@ -96,12 +96,12 @@ def test_init_and_Popen_run( cmd_proc.communicate() assert cmd_proc.returncode == 0 - proc = subprocess.run(*args, **kwargs) + proc = subprocess.run(*args, **kwargs, check=False) assert proc.returncode == 0 @pytest.mark.parametrize( - "args,kwargs,expected_result", + ("args", "kwargs", "expected_result"), FIXTURES, ids=idfn, ) @@ -122,7 +122,7 @@ def test_init_and_check_call( @pytest.mark.parametrize( - "args,kwargs,expected_result", + ("args", "kwargs", "expected_result"), FIXTURES, ) def test_init_and_check_output( @@ -142,11 +142,11 @@ def test_init_and_check_output( @pytest.mark.parametrize( - "args,kwargs,run_kwargs", + ("args", "kwargs", "run_kwargs"), [ - [["ls"], {}, {}], - [[["ls", "-l"]], {}, {}], - [[["ls", "-al"]], {}, {"stdout": subprocess.DEVNULL}], + (["ls"], {}, {}), + ([["ls", "-l"]], {}, {}), + ([["ls", "-al"]], {}, {"stdout": subprocess.DEVNULL}), ], ids=idfn, ) diff --git a/tests/_internal/test_query_list.py b/tests/_internal/test_query_list.py index 9c091a5b..cbee4f37 100644 --- a/tests/_internal/test_query_list.py +++ b/tests/_internal/test_query_list.py @@ -17,120 +17,120 @@ class Obj: @pytest.mark.parametrize( - "items,filter_expr,expected_result", + ("items", "filter_expr", "expected_result"), [ - [[Obj(test=1)], None, [Obj(test=1)]], - [[Obj(test=1)], {"test": 1}, [Obj(test=1)]], - [[Obj(test=1)], {"test": 2}, []], - [ + ([Obj(test=1)], None, [Obj(test=1)]), + ([Obj(test=1)], {"test": 1}, [Obj(test=1)]), + ([Obj(test=1)], {"test": 2}, []), + ( [Obj(test=2, fruit=["apple"])], {"fruit__in": "apple"}, QueryList([Obj(test=2, fruit=["apple"])]), - ], - [[{"test": 1}], None, [{"test": 1}]], - [[{"test": 1}], None, QueryList([{"test": 1}])], - [[{"fruit": "apple"}], None, QueryList([{"fruit": "apple"}])], - [ + ), + ([{"test": 1}], None, [{"test": 1}]), + ([{"test": 1}], None, QueryList([{"test": 1}])), + ([{"fruit": "apple"}], None, QueryList([{"fruit": "apple"}])), + ( [{"fruit": "apple", "banana": object()}], None, QueryList([{"fruit": "apple", "banana": object()}]), - ], - [ + ), + ( [{"fruit": "apple", "banana": object()}], {"fruit__eq": "apple"}, QueryList([{"fruit": "apple", "banana": object()}]), - ], - [ + ), + ( [{"fruit": "apple", "banana": object()}], {"fruit__eq": "notmatch"}, QueryList([]), - ], - [ + ), + ( [{"fruit": "apple", "banana": object()}], {"fruit__exact": "apple"}, QueryList([{"fruit": "apple", "banana": object()}]), - ], - [ + ), + ( [{"fruit": "apple", "banana": object()}], {"fruit__exact": "notmatch"}, QueryList([]), - ], - [ + ), + ( [{"fruit": "apple", "banana": object()}], {"fruit__iexact": "Apple"}, QueryList([{"fruit": "apple", "banana": object()}]), - ], - [ + ), + ( [{"fruit": "apple", "banana": object()}], {"fruit__iexact": "Notmatch"}, QueryList([]), - ], - [ + ), + ( [{"fruit": "apple", "banana": object()}], {"fruit": "notmatch"}, QueryList([]), - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit": "apple"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__in": "app"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__icontains": "App"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__contains": "app"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__regex": r"app.*"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__iregex": r"App.*"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__startswith": "a"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__istartswith": "AP"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__startswith": "z"}, [], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__endswith": "le"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__iendswith": "LE"}, [{"fruit": "apple"}], - ], - [ + ), + ( [{"fruit": "apple"}, {"fruit": "mango"}], {"fruit__endswith": "z"}, [], - ], - [ + ), + ( [ {"fruit": "apple"}, {"fruit": "mango"}, @@ -139,8 +139,8 @@ class Obj: ], {"fruit__in": ["apple", "mango"]}, [{"fruit": "apple"}, {"fruit": "mango"}], - ], - [ + ), + ( [ {"fruit": "apple"}, {"fruit": "mango"}, @@ -149,8 +149,8 @@ class Obj: ], {"fruit__nin": ["apple", "mango"]}, [{"fruit": "banana"}, {"fruit": "kiwi"}], - ], - [ + ), + ( [ {"place": "book store", "city": "Tampa", "state": "Florida"}, {"place": "coffee shop", "city": "Tampa", "state": "Florida"}, @@ -170,8 +170,8 @@ class Obj: {"place": "book store", "city": "Tampa", "state": "Florida"}, {"place": "coffee shop", "city": "Tampa", "state": "Florida"}, ], - ], - [ + ), + ( [ {"place": "book store", "city": "Tampa", "state": "Florida"}, {"place": "coffee shop", "city": "Tampa", "state": "Florida"}, @@ -190,8 +190,8 @@ class Obj: [ {"place": "coffee shop", "city": "Tampa", "state": "Florida"}, ], - ], - [ + ), + ( [ { "place": "Largo", @@ -215,8 +215,8 @@ class Obj: "foods": {"fruit": ["banana", "orange"], "breakfast": "cereal"}, }, ], - ], - [ + ), + ( [ { "place": "Largo", @@ -240,12 +240,12 @@ class Obj: "foods": {"fruit": ["banana", "orange"], "breakfast": "cereal"}, }, ], - ], - [[1, 2, 3, 4, 5], None, QueryList([1, 2, 3, 4, 5])], - [[1, 2, 3, 4, 5], [1], QueryList([1])], - [[1, 2, 3, 4, 5], [1, 4], QueryList([1, 4])], - [[1, 2, 3, 4, 5], lambda val: val == 1, QueryList([1])], - [[1, 2, 3, 4, 5], lambda val: val == 2, QueryList([2])], + ), + ([1, 2, 3, 4, 5], None, QueryList([1, 2, 3, 4, 5])), + ([1, 2, 3, 4, 5], [1], QueryList([1])), + ([1, 2, 3, 4, 5], [1, 4], QueryList([1, 4])), + ([1, 2, 3, 4, 5], lambda val: val == 1, QueryList([1])), + ([1, 2, 3, 4, 5], lambda val: val == 2, QueryList([2])), ], ) def test_filter( diff --git a/tests/sync/test_git.py b/tests/sync/test_git.py index b00bad6e..48a1f85c 100644 --- a/tests/sync/test_git.py +++ b/tests/sync/test_git.py @@ -32,24 +32,24 @@ @pytest.mark.parametrize( # Postpone evaluation of options so fixture variables can interpolate - "constructor,lazy_constructor_options", + ("constructor", "lazy_constructor_options"), [ - [ + ( GitSync, lambda bare_dir, tmp_path, **kwargs: { "url": bare_dir.as_uri(), "path": tmp_path / "obtaining a bare repo", "vcs": "git", }, - ], - [ + ), + ( create_project, lambda bare_dir, tmp_path, **kwargs: { "url": f"git+{bare_dir.as_uri()}", "path": tmp_path / "obtaining a bare repo", "vcs": "git", }, - ], + ), ], ) def test_repo_git_obtain_initial_commit_repo( @@ -75,24 +75,24 @@ def test_repo_git_obtain_initial_commit_repo( @pytest.mark.parametrize( # Postpone evaluation of options so fixture variables can interpolate - "constructor,lazy_constructor_options", + ("constructor", "lazy_constructor_options"), [ - [ + ( GitSync, lambda git_remote_repo, tmp_path, **kwargs: { "url": git_remote_repo.as_uri(), "path": tmp_path / "myrepo", "vcs": "git", }, - ], - [ + ), + ( create_project, lambda git_remote_repo, tmp_path, **kwargs: { "url": f"git+{git_remote_repo.as_uri()}", "path": tmp_path / "myrepo", "vcs": "git", }, - ], + ), ], ) def test_repo_git_obtain_full( @@ -113,24 +113,24 @@ def test_repo_git_obtain_full( @pytest.mark.parametrize( # Postpone evaluation of options so fixture variables can interpolate - "constructor,lazy_constructor_options", + ("constructor", "lazy_constructor_options"), [ - [ + ( GitSync, lambda git_remote_repo, tmp_path, **kwargs: { "url": git_remote_repo.as_uri(), "path": tmp_path / "myrepo", "vcs": "git", }, - ], - [ + ), + ( create_project, lambda git_remote_repo, tmp_path, **kwargs: { "url": f"git+{git_remote_repo.as_uri()}", "path": tmp_path / "myrepo", "vcs": "git", }, - ], + ), ], ) def test_repo_update_handle_cases( @@ -158,16 +158,16 @@ def test_repo_update_handle_cases( @pytest.mark.parametrize( - "has_untracked_files,needs_stash,has_remote_changes", + ("has_untracked_files", "needs_stash", "has_remote_changes"), [ - [True, True, True], - [True, True, False], - [True, False, True], - [True, False, False], - [False, True, True], - [False, True, False], - [False, False, True], - [False, False, False], + (True, True, True), + (True, True, False), + (True, False, True), + (True, False, False), + (False, True, True), + (False, True, False), + (False, False, True), + (False, False, False), ], ) def test_repo_update_stash_cases( @@ -223,9 +223,9 @@ def test_repo_update_stash_cases( @pytest.mark.parametrize( # Postpone evaluation of options so fixture variables can interpolate - "constructor,lazy_constructor_options", + ("constructor", "lazy_constructor_options"), [ - [ + ( GitSync, lambda git_remote_repo, tmp_path, progress_callback, **kwargs: { "url": git_remote_repo.as_uri(), @@ -233,8 +233,8 @@ def test_repo_update_stash_cases( "progress_callback": progress_callback, "vcs": "git", }, - ], - [ + ), + ( create_project, lambda git_remote_repo, tmp_path, progress_callback, **kwargs: { "url": f"git+{git_remote_repo.as_uri()}", @@ -242,7 +242,7 @@ def test_repo_update_stash_cases( "progress_callback": progress_callback, "vcs": "git", }, - ], + ), ], ) def test_progress_callback( @@ -272,9 +272,9 @@ def progress_callback_spy(output: str, timestamp: datetime.datetime) -> None: @pytest.mark.parametrize( # Postpone evaluation of options so fixture variables can interpolate - "constructor,lazy_constructor_options,lazy_remote_expected", + ("constructor", "lazy_constructor_options", "lazy_remote_expected"), [ - [ + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -287,8 +287,8 @@ def progress_callback_spy(output: str, timestamp: datetime.datetime) -> None: push_url=git_remote_repo.as_uri(), ), }, - ], - [ + ), + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -302,8 +302,8 @@ def progress_callback_spy(output: str, timestamp: datetime.datetime) -> None: push_url=git_remote_repo.as_uri(), ), }, - ], - [ + ), + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -325,8 +325,8 @@ def progress_callback_spy(output: str, timestamp: datetime.datetime) -> None: push_url=git_remote_repo.as_uri(), ), }, - ], - [ + ), + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -347,8 +347,8 @@ def progress_callback_spy(output: str, timestamp: datetime.datetime) -> None: push_url=git_remote_repo.as_uri(), ), }, - ], - [ + ), + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -378,8 +378,8 @@ def progress_callback_spy(output: str, timestamp: datetime.datetime) -> None: push_url=git_remote_repo.as_uri(), ), }, - ], - [ + ), + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -400,8 +400,8 @@ def progress_callback_spy(output: str, timestamp: datetime.datetime) -> None: push_url=git_remote_repo.as_uri(), ), }, - ], - [ + ), + ( create_project, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": f"git+{git_remote_repo.as_uri()}", @@ -415,7 +415,7 @@ def progress_callback_spy(output: str, timestamp: datetime.datetime) -> None: push_url=git_remote_repo.as_uri(), ), }, - ], + ), ], ) def test_remotes( @@ -447,9 +447,14 @@ def test_remotes( @pytest.mark.parametrize( # Postpone evaluation of options so fixture variables can interpolate - "constructor,lazy_constructor_options,lazy_remote_dict,lazy_remote_expected", + ( + "constructor", + "lazy_constructor_options", + "lazy_remote_dict", + "lazy_remote_expected", + ), [ - [ + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -460,11 +465,9 @@ def test_remotes( }, lambda git_remote_repo, **kwargs: { "second_remote": GitRemote( - **{ - "name": "second_remote", - "fetch_url": git_remote_repo.as_uri(), - "push_url": git_remote_repo.as_uri(), - }, + name="second_remote", + fetch_url=git_remote_repo.as_uri(), + push_url=git_remote_repo.as_uri(), ), }, lambda git_remote_repo, **kwargs: { @@ -479,8 +482,8 @@ def test_remotes( fetch_url=git_remote_repo.as_uri(), ), }, - ], - [ + ), + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -504,8 +507,8 @@ def test_remotes( fetch_url=git_remote_repo.as_uri(), ), }, - ], - [ + ), + ( GitSync, lambda git_remote_repo, projects_path, repo_name, **kwargs: { "url": git_remote_repo.as_uri(), @@ -516,11 +519,9 @@ def test_remotes( }, lambda git_remote_repo, second_git_remote_repo, **kwargs: { "origin": GitRemote( - **{ - "name": "second_remote", - "fetch_url": f"{second_git_remote_repo!s}", - "push_url": f"{second_git_remote_repo!s}", - }, + name="second_remote", + fetch_url=f"{second_git_remote_repo!s}", + push_url=f"{second_git_remote_repo!s}", ), }, lambda git_remote_repo, second_git_remote_repo, **kwargs: { @@ -530,7 +531,7 @@ def test_remotes( push_url=f"{second_git_remote_repo!s}", ), }, - ], + ), ], ) def test_remotes_update_repo( @@ -590,24 +591,24 @@ def test_git_get_url_and_rev_from_pip_url() -> None: @pytest.mark.parametrize( # Postpone evaluation of options so fixture variables can interpolate - "constructor,lazy_constructor_options", + ("constructor", "lazy_constructor_options"), [ - [ + ( GitSync, lambda git_remote_repo, path, **kwargs: { "url": git_remote_repo.as_uri(), "path": path, "vcs": "git", }, - ], - [ + ), + ( create_project, lambda git_remote_repo, path, **kwargs: { "url": f"git+{git_remote_repo.as_uri()}", "path": path, "vcs": "git", }, - ], + ), ], ) def test_remotes_preserves_git_ssh( @@ -634,24 +635,24 @@ def test_remotes_preserves_git_ssh( @pytest.mark.parametrize( # Postpone evaluation of options so fixture variables can interpolate - "constructor,lazy_constructor_options", + ("constructor", "lazy_constructor_options"), [ - [ + ( GitSync, lambda bare_dir, tmp_path, **kwargs: { "url": bare_dir.as_uri(), "path": tmp_path / "obtaining a bare repo", "vcs": "git", }, - ], - [ + ), + ( create_project, lambda bare_dir, tmp_path, **kwargs: { "url": f"git+{bare_dir.as_uri()}", "path": tmp_path / "obtaining a bare repo", "vcs": "git", }, - ], + ), ], ) def test_private_ssh_format( @@ -683,9 +684,9 @@ def test_git_sync_remotes(git_repo: GitSync) -> None: @pytest.mark.parametrize( - "repo_name,new_repo_url", + ("repo_name", "new_repo_url"), [ - ["myrepo", "file:///apples"], + ("myrepo", "file:///apples"), ], ) def test_set_remote(git_repo: GitSync, repo_name: str, new_repo_url: str) -> None: @@ -740,7 +741,9 @@ def test_get_current_remote_name(git_repo: GitSync) -> None: new_remote_name = "new_remote_name" git_repo.set_remote( - name=new_remote_name, url=git_repo.path.as_uri(), overwrite=True + name=new_remote_name, + url=git_repo.path.as_uri(), + overwrite=True, ) git_repo.run(["fetch", new_remote_name]) git_repo.run(["branch", "--set-upstream-to", f"{new_remote_name}/{new_branch}"]) @@ -775,10 +778,8 @@ def test_GitRemote_from_stdout() -> None: """, # NOQA: E501 ) assert GitStatus( - **{ - "branch_oid": "d4ccd4d6af04b53949f89fbf0cdae13719dc5a08", - "branch_head": "fix-current-remote-name", - }, + branch_oid="d4ccd4d6af04b53949f89fbf0cdae13719dc5a08", + branch_head="fix-current-remote-name", ) == GitStatus.from_stdout(FIXTURE_A) @@ -794,9 +795,9 @@ class GitBranchComplexResult(t.TypedDict): @pytest.mark.parametrize( - "fixture,expected_result", + ("fixture", "expected_result"), [ - [ + ( """ # branch.oid de6185fde0806e5c7754ca05676325a1ea4d6348 # branch.head fix-current-remote-name @@ -806,21 +807,19 @@ class GitBranchComplexResult(t.TypedDict): 1 .M N... 100644 100644 100644 302ca2c18d4c295ce217bff5f93e1ba342dc6665 302ca2c18d4c295ce217bff5f93e1ba342dc6665 tests/test_git.py """, # NOQA: E501 GitStatus( - **{ - "branch_oid": "de6185fde0806e5c7754ca05676325a1ea4d6348", - "branch_head": "fix-current-remote-name", - "branch_upstream": "origin/fix-current-remote-name", - "branch_ab": "+0 -0", - "branch_ahead": "0", - "branch_behind": "0", - }, + branch_oid="de6185fde0806e5c7754ca05676325a1ea4d6348", + branch_head="fix-current-remote-name", + branch_upstream="origin/fix-current-remote-name", + branch_ab="+0 -0", + branch_ahead="0", + branch_behind="0", ), - ], - [ + ), + ( "# branch.upstream moo/origin/myslash/remote", - GitStatus(**{"branch_upstream": "moo/origin/myslash/remote"}), - ], - [ + GitStatus(branch_upstream="moo/origin/myslash/remote"), + ), + ( """ # branch.oid c3c5323abc5dca78d9bdeba6c163c2a37b452e69 # branch.head libvcs-0.4.0 @@ -828,16 +827,14 @@ class GitBranchComplexResult(t.TypedDict): # branch.ab +0 -0 """, GitStatus( - **{ - "branch_oid": "c3c5323abc5dca78d9bdeba6c163c2a37b452e69", - "branch_head": "libvcs-0.4.0", - "branch_upstream": "origin/libvcs-0.4.0", - "branch_ab": "+0 -0", - "branch_ahead": "0", - "branch_behind": "0", - }, + branch_oid="c3c5323abc5dca78d9bdeba6c163c2a37b452e69", + branch_head="libvcs-0.4.0", + branch_upstream="origin/libvcs-0.4.0", + branch_ab="+0 -0", + branch_ahead="0", + branch_behind="0", ), - ], + ), ], ) def test_GitRemote__from_stdout_b(fixture: str, expected_result: GitStatus) -> None: @@ -854,54 +851,46 @@ class GitBranchResult(t.TypedDict): @pytest.mark.parametrize( - "fixture,expected_result", + ("fixture", "expected_result"), [ - [ + ( "# branch.ab +1 -83", GitStatus( - **{ - "branch_ab": "+1 -83", - "branch_ahead": "1", - "branch_behind": "83", - }, + branch_ab="+1 -83", + branch_ahead="1", + branch_behind="83", ), - ], - [ + ), + ( """ # branch.ab +0 -0 """, GitStatus( - **{ - "branch_ab": "+0 -0", - "branch_ahead": "0", - "branch_behind": "0", - }, + branch_ab="+0 -0", + branch_ahead="0", + branch_behind="0", ), - ], - [ + ), + ( """ # branch.ab +1 -83 """, GitStatus( - **{ - "branch_ab": "+1 -83", - "branch_ahead": "1", - "branch_behind": "83", - }, + branch_ab="+1 -83", + branch_ahead="1", + branch_behind="83", ), - ], - [ + ), + ( """ # branch.ab +9999999 -9999999 """, GitStatus( - **{ - "branch_ab": "+9999999 -9999999", - "branch_ahead": "9999999", - "branch_behind": "9999999", - }, + branch_ab="+9999999 -9999999", + branch_ahead="9999999", + branch_behind="9999999", ), - ], + ), ], ) def test_GitRemote__from_stdout_c(fixture: str, expected_result: GitStatus) -> None: diff --git a/tests/test_shortcuts.py b/tests/test_shortcuts.py index 451a7410..ef052231 100644 --- a/tests/test_shortcuts.py +++ b/tests/test_shortcuts.py @@ -25,7 +25,7 @@ class CreateProjectKwargsDict(TypedDict, total=False): @pytest.mark.parametrize( - "repo_dict,repo_class,raises_exception", + ("repo_dict", "repo_class", "raises_exception"), [ ( {"url": "https://github.com/freebsd/freebsd.git", "vcs": "git"}, diff --git a/tests/url/test_git.py b/tests/url/test_git.py index c6020e62..b84454e8 100644 --- a/tests/url/test_git.py +++ b/tests/url/test_git.py @@ -76,7 +76,7 @@ class GitURLFixture(typing.NamedTuple): @pytest.mark.parametrize( - "url,is_valid,git_url", + ("url", "is_valid", "git_url"), TEST_FIXTURES, ) def test_git_url( @@ -139,7 +139,7 @@ class GitURLKwargsFixture(typing.NamedTuple): @pytest.mark.parametrize( - "url,is_valid,git_url_kwargs", + ("url", "is_valid", "git_url_kwargs"), PIP_TEST_FIXTURES, ) def test_git_url_extension_pip( @@ -177,7 +177,7 @@ class ToURLFixture(typing.NamedTuple): @pytest.mark.parametrize( - "git_url,expected", + ("git_url", "expected"), [ ToURLFixture( expected="https://github.com/vcs-python/libvcs.git", @@ -241,7 +241,7 @@ class RevFixture(typing.NamedTuple): @pytest.mark.parametrize( - "git_url_kwargs,expected", + ("git_url_kwargs", "expected"), [ RevFixture( expected=None, diff --git a/tests/url/test_hg.py b/tests/url/test_hg.py index 972e35f0..ac29df22 100644 --- a/tests/url/test_hg.py +++ b/tests/url/test_hg.py @@ -42,7 +42,7 @@ class HgURLFixture(typing.NamedTuple): @pytest.mark.parametrize( - "url,is_valid,hg_url", + ("url", "is_valid", "hg_url"), TEST_FIXTURES, ) def test_hg_url( @@ -105,7 +105,7 @@ class HgURLKwargsFixture(typing.NamedTuple): @pytest.mark.parametrize( - "url,is_valid,hg_url_kwargs", + ("url", "is_valid", "hg_url_kwargs"), PIP_TEST_FIXTURES, ) def test_hg_url_extension_pip( @@ -143,17 +143,8 @@ class ToURLFixture(typing.NamedTuple): @pytest.mark.parametrize( - "hg_url,expected", + ("hg_url", "expected"), [ - ToURLFixture( - expected="https://bitbucket.com/vcs-python/libvcs", - hg_url=HgURL( - url="https://bitbucket.com/vcs-python/libvcs", - scheme="https", - hostname="bitbucket.com", - path="vcs-python/libvcs", - ), - ), ToURLFixture( expected="https://bitbucket.com/vcs-python/libvcs", hg_url=HgURL( diff --git a/tests/url/test_registry.py b/tests/url/test_registry.py index 97a90f10..0f5886c4 100644 --- a/tests/url/test_registry.py +++ b/tests/url/test_registry.py @@ -95,7 +95,7 @@ def test_registry( # Just add water expected_matches: list["DetectVCSFixtureExpectedMatch"] = [] - for _idx, expected_match in enumerate(expected_matches_lazy): + for expected_match in expected_matches_lazy: if callable(expected_match): assert callable(expected_match) expected_matches.append(expected_match(url)) diff --git a/tests/url/test_svn.py b/tests/url/test_svn.py index c1cca631..1a5c895c 100644 --- a/tests/url/test_svn.py +++ b/tests/url/test_svn.py @@ -65,7 +65,7 @@ class SvnURLFixture(typing.NamedTuple): @pytest.mark.parametrize( - "url,is_valid,svn_url", + ("url", "is_valid", "svn_url"), TEST_FIXTURES, ) def test_svn_url( @@ -122,7 +122,7 @@ class SvnURLKwargsFixture(typing.NamedTuple): @pytest.mark.parametrize( - "url,is_valid,svn_url_kwargs", + ("url", "is_valid", "svn_url_kwargs"), PIP_TEST_FIXTURES, ) def test_svn_url_extension_pip( @@ -163,17 +163,8 @@ class ToURLFixture(typing.NamedTuple): @pytest.mark.parametrize( - "svn_url,expected", + ("svn_url", "expected"), [ - ToURLFixture( - expected="https://bitbucket.com/vcs-python/libvcs", - svn_url=SvnURL( - url="https://bitbucket.com/vcs-python/libvcs", - scheme="https", - hostname="bitbucket.com", - path="vcs-python/libvcs", - ), - ), ToURLFixture( expected="https://bitbucket.com/vcs-python/libvcs", svn_url=SvnURL(