Commit ccd09a29 by Randy Döring

chore(tests): avoid unnecessary parsing

parent 66d36520
......@@ -12,7 +12,6 @@ from pathlib import Path
from typing import TYPE_CHECKING
import pytest
import tomlkit
from poetry.core.constraints.version import Version
from poetry.core.packages.package import Package
......@@ -231,9 +230,8 @@ python-versions = "~2.7 || ^3.4"
content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77"
""" # noqa: E800
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string())
f.write(content)
packages = locker.locked_repository().packages
......@@ -296,9 +294,8 @@ lock-version = "2.0"
content-hash = "123456789"
""" # noqa: E800
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string())
f.write(content)
repository = locker.locked_repository()
assert len(repository.packages) == 3
......@@ -363,9 +360,8 @@ lock-version = "2.0"
content-hash = "123456789"
""" # noqa: E800
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string())
f.write(content)
repository = locker.locked_repository()
assert len(repository.packages) == 2
......@@ -405,9 +401,8 @@ lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string())
f.write(content)
repository = locker.locked_repository()
assert len(repository.packages) == 1
......@@ -503,9 +498,8 @@ demo = [
{file = "demo-1.0-py3-none-any.whl", hash = "sha256"},
]
"""
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string())
f.write(content)
repository = locker.locked_repository()
assert len(repository.packages) == 5
......@@ -697,9 +691,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
"""
caplog.set_level(logging.WARNING, logger="poetry.packages.locker")
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string())
f.write(content)
_ = locker.lock_data
......@@ -729,9 +722,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
""" # noqa: E800
caplog.set_level(logging.WARNING, logger="poetry.packages.locker")
data = tomlkit.parse(content)
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"):
_ = locker.lock_data
......@@ -824,9 +816,8 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
"""
caplog.set_level(logging.WARNING, logger="poetry.packages.locker")
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string())
f.write(content)
_ = locker.lock_data
......@@ -1031,9 +1022,8 @@ python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
""" # noqa: E800
data = tomlkit.parse(content)
with open(locker.lock, "w", encoding="utf-8") as f:
f.write(data.as_string())
f.write(content)
create_dependency_patch = mocker.patch(
"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