Skip to content

Commit 942d872

Browse files
committed
ch03: transform into a pytest plugin
1 parent f56b79c commit 942d872

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

chapter03-python-packages/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[project]
22
name = "random-wikipedia-article"
33
version = "0.1"
4+
dependencies = ["pytest"]
45

5-
[project.scripts]
6-
random-wikipedia-article = "random_wikipedia_article:main"
6+
[project.entry-points.pytest11]
7+
random-wikipedia-article = "random_wikipedia_article"
78

89
[build-system]
910
requires = ["hatchling"]
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import json
2-
import textwrap
32
import urllib.request
43

4+
import pytest
5+
56
API_URL = "https://en.wikipedia.org/api/rest_v1/page/random/summary"
67

78

8-
def main():
9+
@pytest.fixture
10+
def random_wikipedia_article():
911
with urllib.request.urlopen(API_URL) as response:
10-
data = json.load(response)
11-
12-
print(data["title"], end="\n\n")
13-
print(textwrap.fill(data["extract"]))
12+
return json.load(response)

chapter03-python-packages/src/random_wikipedia_article/__main__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)