Skip to content

Commit a7b484b

Browse files
committed
Add pytest env plugin 😤
1 parent 4b9379f commit a7b484b

File tree

6 files changed

+46
-7
lines changed

6 files changed

+46
-7
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
### 2.2.0 🚜 ongoing work
1+
### 2.3.0 🚜 ongoing work
22

3-
## 2.1.0 📦 current package
3+
## 2.2.0 📦 current package
4+
5+
* Fix obtaining downloads data for the package
6+
* Allow storing settings in the configuration file
7+
8+
## 2.1.0
49

510
* Properly parse author/email/homepage/license from the fields available
611
* Use [pydantic-settings](https://docs.pydantic.dev/latest/concepts/pydantic_settings/) for configuration management

leak/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import click
55

6-
from leak import logger, main, settings
6+
from leak import logger, main, rprint, settings
77
from leak.ui import warning
88

99
config = settings.config
@@ -91,6 +91,8 @@ def set_config_value(set_value: str):
9191
with open(settings.CONFIG_FILEPATH, "w") as f:
9292
config_parser.write(f)
9393

94+
rprint(f"Configuration value for [bold red]{key}[/] updated.")
95+
9496

9597
if __name__ == "__main__":
9698
cli()

leak/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def main(package_name: str = "", showall: bool = False):
5656
package_data = get_package_data(package_name)
5757
except ValueError as e:
5858
logger.error(e)
59-
console.print(f"No such package [bold red]{package_name}[/]")
59+
console.print(f"No such package [bold red]{package_name}[/].")
6060
return sys.exit(1)
6161

6262
releases = package_data["releases"]

poetry.lock

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "leak"
3-
version = "2.1.0"
3+
version = "2.2.0"
44
description = "Show release information about packages on PyPI"
55
authors = [
66
{ name = "Misha Behersky", email = "bmwant@gmail.com" },
@@ -49,15 +49,20 @@ Repository = "https://github.com/bmwant/leak"
4949
pytest = "^8.4.0"
5050
tox = "^4.26.0"
5151
ruff = "^0.11.12"
52+
pytest-env = "^1.1.5"
5253

5354
[tool.ruff.lint]
5455
extend-select = [
5556
# isort
5657
"I",
5758
]
5859

60+
[tool.pytest_env]
61+
LEAK_SHOW_DOWNLOADS = true
62+
LEAK_API_KEY = ""
63+
5964
[project.scripts]
60-
leak = 'leak.cli:cli'
65+
leak = "leak.cli:cli"
6166

6267
[build-system]
6368
requires = ["poetry-core>=2.0.0,<3.0.0"]

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import pytest
22
from click.testing import CliRunner
33

4+
from leak import settings
5+
46

57
@pytest.fixture
68
def runner():
79
cli_runner = CliRunner()
810
yield cli_runner
11+
12+
13+
@pytest.fixture(autouse=True)
14+
def patch_settings(monkeypatch):
15+
monkeypatch.setattr(settings.config, "API_KEY", "")
16+
monkeypatch.setattr(settings.config, "SHOW_DOWNLOADS", True)

0 commit comments

Comments
 (0)