Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
6603215f
Unverified
Commit
6603215f
authored
Nov 18, 2019
by
Sébastien Eustace
Committed by
GitHub
Nov 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the error message when the lock file is invalid (#1596)
parent
a030a5f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletions
+36
-1
poetry/packages/locker.py
+5
-1
tests/packages/test_locker.py
+31
-0
No files found.
poetry/packages/locker.py
View file @
6603215f
...
@@ -8,6 +8,7 @@ from tomlkit import document
...
@@ -8,6 +8,7 @@ from tomlkit import document
from
tomlkit
import
inline_table
from
tomlkit
import
inline_table
from
tomlkit
import
item
from
tomlkit
import
item
from
tomlkit
import
table
from
tomlkit
import
table
from
tomlkit.exceptions
import
TOMLKitError
import
poetry.packages
import
poetry.packages
import
poetry.repositories
import
poetry.repositories
...
@@ -217,7 +218,10 @@ class Locker(object):
...
@@ -217,7 +218,10 @@ class Locker(object):
if
not
self
.
_lock
.
exists
():
if
not
self
.
_lock
.
exists
():
raise
RuntimeError
(
"No lockfile found. Unable to read locked packages"
)
raise
RuntimeError
(
"No lockfile found. Unable to read locked packages"
)
return
self
.
_lock
.
read
()
try
:
return
self
.
_lock
.
read
()
except
TOMLKitError
as
e
:
raise
RuntimeError
(
"Unable to read the lock file ({})."
.
format
(
e
))
def
_lock_packages
(
def
_lock_packages
(
self
,
packages
self
,
packages
...
...
tests/packages/test_locker.py
View file @
6603215f
...
@@ -181,3 +181,34 @@ A = []
...
@@ -181,3 +181,34 @@ A = []
content
=
f
.
read
()
content
=
f
.
read
()
assert
expected
==
content
assert
expected
==
content
def
test_reading_lock_file_should_raise_an_error_on_invalid_data
(
locker
):
content
=
u"""[[package]]
category = "main"
description = ""
name = "A"
optional = false
python-versions = "*"
version = "1.0.0"
[package.extras]
foo = ["bar"]
[package.extras]
foo = ["bar"]
[metadata]
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
python-versions = "*"
[metadata.files]
A = []
"""
with
locker
.
lock
.
open
(
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
content
)
with
pytest
.
raises
(
RuntimeError
)
as
e
:
_
=
locker
.
lock_data
assert
"Unable to read the lock file"
in
str
(
e
.
value
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment