Skip to content

Commit

Permalink
Merge pull request #2971 from greysteil/fix-outline-tables
Browse files Browse the repository at this point in the history
Fix parsing of outline tables
  • Loading branch information
techalchemy authored Oct 10, 2018
2 parents 7ba1f65 + a9a2491 commit d3da491
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
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

0 comments on commit d3da491

Please sign in to comment.