Skip to content

Commit f401074

Browse files
jdufresnegaborbernat
authored andcommitted
Improve accuracy of _alwayscopy_not_supported() (#1133)
Previously, this function checked against a whitelist of OSes that were known to be a problem. This did include Fedora, which also fails this test. Rather than chasing endless edge cases, test for this feature programmatically.
1 parent 5545484 commit f401074

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
setup_requires=["setuptools-scm>2, <4"], # readthedocs needs it
4141
extras_require={
4242
"testing": [
43-
"distro",
4443
"pytest >= 3.0.0, <4",
4544
"pytest-cov >= 2.5.1, <3",
4645
"pytest-mock >= 1.10.0, <2",

tests/unit/test_z_cmdline.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import json
22
import os
3-
import platform
43
import re
4+
import shutil
55
import subprocess
66
import sys
7+
import tempfile
78

8-
import distro
99
import py
1010
import pytest
1111

@@ -630,15 +630,24 @@ def test_warning_emitted(cmd, initproj):
630630
def _alwayscopy_not_supported():
631631
# This is due to virtualenv bugs with alwayscopy in some platforms
632632
# see: https://github.com/pypa/virtualenv/issues/565
633-
if hasattr(platform, "linux_distribution"):
634-
_dist = distro.linux_distribution(full_distribution_name=False)
635-
(name, version, arch) = _dist
636-
if any((name == "centos" and version[0] == "7", name == "SuSE" and arch == "x86_64")):
637-
return True
638-
return False
633+
supported = True
634+
tmpdir = tempfile.mkdtemp()
635+
try:
636+
with open(os.devnull) as fp:
637+
subprocess.check_call(
638+
[sys.executable, "-m", "virtualenv", "--always-copy", tmpdir], stdout=fp, stderr=fp
639+
)
640+
except subprocess.CalledProcessError:
641+
supported = False
642+
finally:
643+
shutil.rmtree(tmpdir)
644+
return not supported
639645

640646

641-
@pytest.mark.skipif(_alwayscopy_not_supported(), reason="Platform doesnt support alwayscopy")
647+
alwayscopy_not_supported = _alwayscopy_not_supported()
648+
649+
650+
@pytest.mark.skipif(alwayscopy_not_supported, reason="Platform doesnt support alwayscopy")
642651
def test_alwayscopy(initproj, cmd):
643652
initproj(
644653
"example123",

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ include_trailing_comma = True
145145
force_grid_wrap = 0
146146
line_length = 99
147147
known_first_party = tox,tests
148-
known_third_party = apiclient,distro,docutils,filelock,git,httplib2,oauth2client,packaging,pkg_resources,pluggy,py,pytest,setuptools,six,sphinx,toml
148+
known_third_party = apiclient,docutils,filelock,git,httplib2,oauth2client,packaging,pkg_resources,pluggy,py,pytest,setuptools,six,sphinx,toml
149149
150150
[testenv:release]
151151
description = do a release, required posarg of the version number

0 commit comments

Comments
 (0)