Skip to content

Commit

Permalink
Extract a temp_home fixture.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Sep 24, 2022
1 parent 66d0ccd commit 1587bbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
7 changes: 7 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,10 @@ def suppress_path_mangle(monkeysession):
monkeysession.setattr(
ccompiler.CCompiler, '_make_relative', staticmethod(lambda x: x)
)


@pytest.fixture
def temp_home(tmp_path, monkeypatch):
var = 'USERPROFILE' if platform.system() == 'Windows' else 'HOME'
monkeypatch.setenv(var, str(tmp_path))
return tmp_path
15 changes: 3 additions & 12 deletions distutils/tests/test_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,23 +451,14 @@ def test_long_description(self):
meta = meta.replace('\n' + 8 * ' ', '\n')
assert long_desc in meta

def test_custom_pydistutils(self, tmp_path):
def test_custom_pydistutils(self, temp_home):
"""
pydistutils.cfg is found
"""
prefix = '.' * (os.name == 'posix')
filename = prefix + 'pydistutils.cfg'
jaraco.path.build({filename: ''}, tmp_path)
config_path = tmp_path / filename

# linux-style
if sys.platform in ('linux', 'darwin'):
os.environ['HOME'] = str(tmp_path)

# win32-style
if sys.platform == 'win32':
# home drive should be found
os.environ['USERPROFILE'] = str(tmp_path)
jaraco.path.build({filename: ''}, temp_home)
config_path = temp_home / filename

assert str(config_path) in Distribution().find_config_files()

Expand Down

0 comments on commit 1587bbb

Please sign in to comment.