Merge branch '2504-fix-array-element-serialization' of https://github.com/JacobHayes/pipenv into 2504-fix-array-element-serialization

This commit is contained in:
Tzu-ping Chung
2018-07-13 14:43:34 +08:00
2 changed files with 29 additions and 2 deletions
+8 -1
View File
@@ -64,6 +64,12 @@ def _normalized(p):
DEFAULT_NEWLINES = u"\n"
def encode_toml_elements(obj):
if hasattr(obj, 'primitive_value'):
return obj.primitive_value
raise TypeError(repr(obj) + " is not JSON serializable")
def preferred_newlines(f):
if isinstance(f.newlines, six.text_type):
return f.newlines
@@ -631,7 +637,8 @@ class Project(object):
"""
newlines = self._lockfile_newlines
s = simplejson.dumps( # Send Unicode in to guarentee Unicode out.
content, indent=4, separators=(u",", u": "), sort_keys=True
content, indent=4, separators=(u",", u": "), sort_keys=True,
default=encode_toml_elements,
)
with atomic_open_for_write(self.lockfile_location, newline=newlines) as f:
f.write(s)
+21 -1
View File
@@ -1,6 +1,5 @@
import pytest
import os
import six
from pipenv.utils import temp_environ
@@ -348,6 +347,27 @@ requests = {git = "https://github.com/requests/requests.git", ref = "master", ed
assert c.return_code == 0
@pytest.mark.extras
@pytest.mark.lock
@pytest.mark.vcs
@pytest.mark.needs_internet
def test_lock_editable_vcs_with_extras_without_install(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
[packages]
requests = {git = "https://github.com/requests/requests.git", editable = true, extras = ["socks"]}
""".strip())
c = p.pipenv('lock')
assert c.return_code == 0
assert 'requests' in p.lockfile['default']
assert 'idna' in p.lockfile['default']
assert 'chardet' in p.lockfile['default']
assert "socks" in p.lockfile["default"]["requests"]["extras"]
c = p.pipenv('install')
assert c.return_code == 0
@pytest.mark.lock
@pytest.mark.skip(reason="This doesn't work for some reason.")
def test_lock_respecting_python_version(PipenvInstance, pypi):