aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Ganssle <paul@ganssle.io>2018-11-06 11:51:42 -0500
committerPaul Ganssle <paul@ganssle.io>2018-11-07 17:38:42 -0500
commitbef22678626f4e201ef1bb6c5bc753dd01e6bf5a (patch)
tree419e5b8e04d080def5ca304b7bf8e0f0e88e5c14
parentc34962d08168e0149a71485f1f71ddfd22146140 (diff)
downloadexternal_python_setuptools-bef22678626f4e201ef1bb6c5bc753dd01e6bf5a.tar.gz
external_python_setuptools-bef22678626f4e201ef1bb6c5bc753dd01e6bf5a.tar.bz2
external_python_setuptools-bef22678626f4e201ef1bb6c5bc753dd01e6bf5a.zip
Use an in-memory IO object instead of a temp file
Rather than writing to a file in a temporary directory, we can write to and read from an in-memory buffer, now that the encoding functionality in write_pkg_file is fixed.
-rw-r--r--setuptools/tests/test_dist.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/setuptools/tests/test_dist.py b/setuptools/tests/test_dist.py
index 36605cea..a7f4452b 100644
--- a/setuptools/tests/test_dist.py
+++ b/setuptools/tests/test_dist.py
@@ -12,6 +12,7 @@ from .textwrap import DALS
from .test_easy_install import make_nspkg_sdist
import pytest
+import six
def test_dist_fetch_build_egg(tmpdir):
@@ -120,20 +121,22 @@ def __read_test_cases():
@pytest.mark.parametrize('name,attrs', __read_test_cases())
-def test_read_metadata(name, attrs, tmpdir):
+def test_read_metadata(name, attrs):
dist = Distribution(attrs)
metadata_out = dist.metadata
dist_class = metadata_out.__class__
# Write to PKG_INFO and then load into a new metadata object
- fn = tmpdir.mkdir('pkg_info')
- fn_s = str(fn)
+ if six.PY2:
+ PKG_INFO = io.BytesIO()
+ else:
+ PKG_INFO = io.StringIO()
- metadata_out.write_pkg_info(fn_s)
+ metadata_out.write_pkg_file(PKG_INFO)
+ PKG_INFO.seek(0)
metadata_in = dist_class()
- with io.open(str(fn.join('PKG-INFO')), 'r', encoding='utf-8') as f:
- metadata_in.read_pkg_file(f)
+ metadata_in.read_pkg_file(PKG_INFO)
tested_attrs = [
('name', dist_class.get_name),