Skip to content

Commit 99f6e1e

Browse files
committed
improve testing
1 parent 6622d3e commit 99f6e1e

File tree

6 files changed

+84
-5
lines changed

6 files changed

+84
-5
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__pycache__
22
dist
33
.venv
4-
tests/poetry.lock
5-
tests/*.toml
4+
tests/*.lock
5+
tests/pyproject.toml

poetry.lock

Lines changed: 13 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ wheel = "0.37.1" # I still don't get why wheel is not shipped with pip or standa
2424
tox = "^3.25.0"
2525
tox-poetry = "^0.4.1"
2626
black = "^22.6.0"
27+
pip = "^22.2.2"
28+
29+
30+
31+
2732

2833

2934

tests/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import shutil
3+
import subprocess
34

45
from pytest import fixture
56
from tomlkit import TOMLDocument
@@ -14,12 +15,16 @@ def prepare_tests():
1415
@fixture(autouse=True)
1516
def yield_example():
1617
shutil.copy2("pyproject.toml.example", "pyproject.toml")
17-
yield
18-
os.remove("pyproject.toml")
1918
try:
2019
os.remove("poetry.lock")
2120
except FileNotFoundError:
2221
pass
22+
subprocess.run(["poetry", "install"])
23+
yield
24+
subprocess.run(
25+
["python", "-m", "poetry", "remove", "--group", "types", "types-requests"]
26+
)
27+
# os.remove("pyproject.toml")
2328

2429

2530
class CustomTOMLFile(TOMLFile):

tests/poetry.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[virtualenvs]
2+
create = true
3+
in-project = true

tests/test_commands.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@
33
import subprocess
44

55
import pytest
6+
67
from conftest import CustomTOMLFile
78

89

910
@pytest.mark.parametrize("command", [["types", "update"]])
1011
def test_update(command: list[str], toml_file: CustomTOMLFile):
12+
assert (
13+
subprocess.run(
14+
["python", "-m", "poetry", "run", "pip", "show", "types-requests"]
15+
).returncode
16+
!= 0
17+
)
18+
19+
assert (
20+
subprocess.run(
21+
["python", "-m", "poetry", "run", "pip", "show", "types-colorama"]
22+
).returncode
23+
== 0
24+
)
25+
1126
content = toml_file.poetry
1227
content["dependencies"].add("requests", "^2.27.1")
1328
del content["dependencies"]["colorama"]
@@ -16,14 +31,53 @@ def test_update(command: list[str], toml_file: CustomTOMLFile):
1631
assert "types-colorama" not in toml_file.poetry["group"]["types"]["dependencies"]
1732
assert "types-requests" in toml_file.poetry["group"]["types"]["dependencies"]
1833

34+
assert (
35+
subprocess.run(
36+
["python", "-m", "poetry", "run", "pip", "show", "types-requests"]
37+
).returncode
38+
== 0
39+
)
40+
assert (
41+
subprocess.run(
42+
["python", "-m", "poetry", "run", "pip", "show", "types-colorama"]
43+
).returncode
44+
!= 0
45+
)
46+
1947

2048
@pytest.mark.parametrize("command", [["types", "add", "requests"]])
2149
def test_add(command: list[str], toml_file: CustomTOMLFile):
50+
assert (
51+
subprocess.run(
52+
["python", "-m", "poetry", "run", "pip", "show", "types-requests"]
53+
).returncode
54+
!= 0
55+
)
56+
2257
subprocess.run(["python", "-m", "poetry", "--verbose", *command])
2358
assert "types-requests" in toml_file.poetry["group"]["types"]["dependencies"]
59+
assert (
60+
subprocess.run(
61+
["python", "-m", "poetry", "run", "pip", "show", "types-requests"]
62+
).returncode
63+
== 0
64+
)
2465

2566

2667
@pytest.mark.parametrize("command", [["types", "remove", "colorama"]])
2768
def test_remove(command: list[str], toml_file: CustomTOMLFile):
69+
assert (
70+
subprocess.run(
71+
["python", "-m", "poetry", "run", "pip", "show", "types-colorama"]
72+
).returncode
73+
== 0
74+
)
75+
2876
subprocess.run(["python", "-m", "poetry", "--verbose", *command])
2977
assert "types-colorama" not in toml_file.poetry["group"]["types"]["dependencies"]
78+
assert (
79+
subprocess.run(
80+
["python", "-m", "poetry", "run", "pip", "show", "types-colorama"]
81+
).returncode
82+
!= 0
83+
)

0 commit comments

Comments
 (0)