Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of outline tables #2971

Merged
merged 2 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2971.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix parsing of outline tables.
9 changes: 5 additions & 4 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,15 @@ def _parse_pipfile(self, contents):
# Convert things to inline tables — fancy :)
if hasattr(data[section][package], "keys"):
_data = data[section][package]
data[section][package] = toml._get_empty_inline_table(dict)
data[section][package] = toml.TomlDecoder().get_empty_inline_table()
data[section][package].update(_data)
toml_encoder = toml.TomlEncoder(preserve=True)
# We lose comments here, but it's for the best.)
try:
return contoml.loads(toml.dumps(data, preserve=True))
return contoml.loads(toml.dumps(data, encoder=toml_encoder))

except RuntimeError:
return toml.loads(toml.dumps(data, preserve=True))
return toml.loads(toml.dumps(data, encoder=toml_encoder))

else:
# Fallback to toml parser, for large files.
Expand Down Expand Up @@ -673,7 +674,7 @@ def write_toml(self, data, path=None):
# Convert things to inline tables — fancy :)
if hasattr(data[section][package], "keys"):
_data = data[section][package]
data[section][package] = toml._get_empty_inline_table(dict)
data[section][package] = toml.TomlDecoder().get_empty_inline_table()
data[section][package].update(_data)
formatted_data = toml.dumps(data).rstrip()

Expand Down
25 changes: 25 additions & 0 deletions tests/integration/test_install_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,31 @@ def test_alternative_version_specifier(PipenvInstance, pypi):
assert c.return_code == 0


@pytest.mark.run
@pytest.mark.alt
@flaky
def test_outline_table_specifier(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
with open(p.pipfile_path, "w") as f:
contents = """
[packages.requests]
version = "*"
""".strip()
f.write(contents)

c = p.pipenv("install")
assert c.return_code == 0

assert "requests" in p.lockfile["default"]
assert "idna" in p.lockfile["default"]
assert "urllib3" in p.lockfile["default"]
assert "certifi" in p.lockfile["default"]
assert "chardet" in p.lockfile["default"]

c = p.pipenv('run python -c "import requests; import idna; import certifi;"')
assert c.return_code == 0


@pytest.mark.bad
@pytest.mark.install
def test_bad_packages(PipenvInstance, pypi):
Expand Down