Commit ccd09a29 by Randy Döring

chore(tests): avoid unnecessary parsing

parent 66d36520
...@@ -12,7 +12,6 @@ from pathlib import Path ...@@ -12,7 +12,6 @@ from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import pytest import pytest
import tomlkit
from poetry.core.constraints.version import Version from poetry.core.constraints.version import Version
from poetry.core.packages.package import Package from poetry.core.packages.package import Package
...@@ -231,9 +230,8 @@ python-versions = "~2.7 || ^3.4" ...@@ -231,9 +230,8 @@ python-versions = "~2.7 || ^3.4"
content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77" content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77"
""" # noqa: E800 """ # noqa: E800
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
packages = locker.locked_repository().packages packages = locker.locked_repository().packages
...@@ -296,9 +294,8 @@ lock-version = "2.0" ...@@ -296,9 +294,8 @@ lock-version = "2.0"
content-hash = "123456789" content-hash = "123456789"
""" # noqa: E800 """ # noqa: E800
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
repository = locker.locked_repository() repository = locker.locked_repository()
assert len(repository.packages) == 3 assert len(repository.packages) == 3
...@@ -363,9 +360,8 @@ lock-version = "2.0" ...@@ -363,9 +360,8 @@ lock-version = "2.0"
content-hash = "123456789" content-hash = "123456789"
""" # noqa: E800 """ # noqa: E800
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
repository = locker.locked_repository() repository = locker.locked_repository()
assert len(repository.packages) == 2 assert len(repository.packages) == 2
...@@ -405,9 +401,8 @@ lock-version = "2.0" ...@@ -405,9 +401,8 @@ lock-version = "2.0"
python-versions = "*" python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8" content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
""" """
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
repository = locker.locked_repository() repository = locker.locked_repository()
assert len(repository.packages) == 1 assert len(repository.packages) == 1
...@@ -503,9 +498,8 @@ demo = [ ...@@ -503,9 +498,8 @@ demo = [
{file = "demo-1.0-py3-none-any.whl", hash = "sha256"}, {file = "demo-1.0-py3-none-any.whl", hash = "sha256"},
] ]
""" """
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
repository = locker.locked_repository() repository = locker.locked_repository()
assert len(repository.packages) == 5 assert len(repository.packages) == 5
...@@ -697,9 +691,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77 ...@@ -697,9 +691,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
""" """
caplog.set_level(logging.WARNING, logger="poetry.packages.locker") caplog.set_level(logging.WARNING, logger="poetry.packages.locker")
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
_ = locker.lock_data _ = locker.lock_data
...@@ -729,9 +722,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77 ...@@ -729,9 +722,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
""" # noqa: E800 """ # noqa: E800
caplog.set_level(logging.WARNING, logger="poetry.packages.locker") caplog.set_level(logging.WARNING, logger="poetry.packages.locker")
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
with pytest.raises(RuntimeError, match="^The lock file is not compatible"): with pytest.raises(RuntimeError, match="^The lock file is not compatible"):
_ = locker.lock_data _ = locker.lock_data
...@@ -824,9 +816,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77 ...@@ -824,9 +816,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
""" """
caplog.set_level(logging.WARNING, logger="poetry.packages.locker") caplog.set_level(logging.WARNING, logger="poetry.packages.locker")
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
_ = locker.lock_data _ = locker.lock_data
...@@ -1031,9 +1022,8 @@ python-versions = "*" ...@@ -1031,9 +1022,8 @@ python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8" content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
""" # noqa: E800 """ # noqa: E800
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f: with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string()) f.write(content)
create_dependency_patch = mocker.patch( create_dependency_patch = mocker.patch(
"poetry.factory.Factory.create_dependency", autospec=True "poetry.factory.Factory.create_dependency", autospec=True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment