Skip to content

Commit 6624518

Browse files
committed
fix
1 parent 591d221 commit 6624518

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

avito/core/swagger_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from avito.core.swagger_names import swagger_field_aliases
1313

1414
HTTP_METHODS = frozenset({"delete", "get", "head", "options", "patch", "post", "put", "trace"})
15-
DEFAULT_SWAGGER_API_DIR = Path("docs/avito/api")
15+
DEFAULT_SWAGGER_API_DIR = Path(__file__).resolve().parents[2] / "docs" / "avito" / "api"
1616

1717
_PATH_PARAMETER_RE = re.compile(r"{([A-Za-z_][A-Za-z0-9_]*)}")
1818

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ authors = ["Nikolay Baryshnikov <root@k0d.ru>"]
66
packages=[
77
{ include = "avito" },
88
]
9+
include = [
10+
{ path = "docs/avito/api/*.json", format = ["sdist", "wheel"] },
11+
]
912
license="MIT"
1013
readme="README.md"
1114
homepage="https://github.com/18studio/avito_python_api"

tests/cli/test_app.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import os
56
import subprocess
67
import sys
78
from pathlib import Path
@@ -116,6 +117,23 @@ def test_version_option_outputs_version() -> None:
116117
assert "avito" in result.output
117118

118119

120+
def test_version_option_works_outside_project_directory(tmp_path: Path) -> None:
121+
env = os.environ.copy()
122+
env["PYTHONPATH"] = str(Path(__file__).resolve().parents[2])
123+
result = subprocess.run(
124+
[sys.executable, "-m", "avito", "--version"],
125+
check=False,
126+
capture_output=True,
127+
cwd=tmp_path,
128+
env=env,
129+
text=True,
130+
)
131+
132+
assert result.returncode == 0
133+
assert result.stdout.startswith("avito-py ")
134+
assert result.stderr == ""
135+
136+
119137
def test_python_module_entrypoint_uses_cli_help(tmp_path: Path) -> None:
120138
result = subprocess.run(
121139
[sys.executable, "-m", "avito", "--help"],

0 commit comments

Comments
 (0)