Skip to content

Commit aa3b220

Browse files
committed
PR feedback
Signed-off-by: Bernát Gábor <[email protected]>
1 parent 18dabbe commit aa3b220

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

src/build/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, exception): # type: (Exception) -> None
4848
super(BuildBackendException, self).__init__()
4949
self.exception = exception # type: Exception
5050

51-
def __repr__(self): # type: () -> str
51+
def __str__(self): # type: () -> str
5252
return 'Backend operation failed: {!r}'.format(self.exception)
5353

5454

tests/test_env.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,15 @@ def test_fail_to_get_script_path(mocker):
6464
@pytest.mark.skipif(sys.version_info[0] == 2, reason='venv module used on Python 3 only')
6565
@pytest.mark.skipif(IS_PYPY3, reason='PyPy3 uses get path to create and provision venv')
6666
def test_fail_to_get_purepath(mocker):
67+
mocker.patch.object(build.env, 'virtualenv', None)
6768
sysconfig_get_path = sysconfig.get_path
68-
69-
def mock_sysconfig_get_path(path, *args, **kwargs):
70-
if path == 'purelib':
71-
return ''
72-
else:
73-
return sysconfig_get_path(path, *args, **kwargs)
74-
75-
mocker.patch('sysconfig.get_path', side_effect=mock_sysconfig_get_path)
69+
mocker.patch(
70+
'sysconfig.get_path',
71+
side_effect=lambda path, *args, **kwargs: '' if path == 'purelib' else sysconfig_get_path(path, *args, **kwargs),
72+
)
7673

7774
with pytest.raises(RuntimeError, match="Couldn't get environment purelib folder"):
78-
env = build.env.IsolatedEnvBuilder()
79-
with env:
75+
with build.env.IsolatedEnvBuilder():
8076
pass
8177

8278

tests/test_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,5 @@ def test_build_raises_build_backend_exception(mocker, test_flit_path):
167167
mocker.patch('build.env._IsolatedEnvVenvPip.install')
168168

169169
build.__main__.build_package(test_flit_path, '.', ['sdist'])
170-
171-
error.assert_called_with('')
170+
msg = "Backend operation failed: Exception('a'{})".format(',' if sys.version_info < (3, 7) else '')
171+
error.assert_called_with(msg)

tests/test_projectbuilder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def test_prepare_error(mocker, tmp_dir, test_flit_path):
414414
builder = build.ProjectBuilder(test_flit_path)
415415
builder._hook.prepare_metadata_for_build_wheel.side_effect = Exception
416416

417-
with pytest.raises(build.BuildBackendException):
417+
with pytest.raises(build.BuildBackendException, match='Backend operation failed: Exception'):
418418
builder.prepare('wheel', tmp_dir)
419419

420420

@@ -426,6 +426,5 @@ def test_prepare_not_dir_outdir(mocker, tmp_dir, test_flit_path):
426426
out = os.path.join(tmp_dir, 'out')
427427
with open(out, 'w') as f:
428428
f.write('Not a directory')
429-
430-
with pytest.raises(build.BuildException):
429+
with pytest.raises(build.BuildException, match='Build path .* exists and is not a directory'):
431430
builder.prepare('wheel', out)

0 commit comments

Comments
 (0)