Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0e08fe

Browse files
committed
Show more information whentest_installation fails
Previously, it attempted to show stderr unless empty, first fallingback to stdout unless empty, then falling back to the prewrittensummary identifying the specific assertion.This now has the `test_installation` assertions capture stderr aswell as stdout, handle standard streams as text rather than binary,and show more information when failing, always distinguishing wherethe information came from: the summary, then labeled capturedstdout (empty or not), then labeled captured stderr (empty or not).That applies to all but the last assertion, which does not try toshow information differently when it fails, but is simplified to dothe right thing now that `subprocess.run` is using text streams.(This subtly changes its semantics, but overall it should be aseffective as before at finding the `sys.path` woe it anticipates.)
1 parenta2ba480 commita0e08fe

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

‎test/test_installation.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,19 @@ def test_installation(self, rw_dir):
1515
venv,run=self._set_up_venv(rw_dir)
1616

1717
result=run([venv.pip,"install","."])
18-
self.assertEqual(
19-
0,
20-
result.returncode,
21-
msg=result.stderrorresult.stdoutor"Can't install project",
22-
)
18+
self._check_result(result,"Can't install project")
2319

2420
result=run([venv.python,"-c","import git"])
25-
self.assertEqual(
26-
0,
27-
result.returncode,
28-
msg=result.stderrorresult.stdoutor"Self-test failed",
29-
)
21+
self._check_result(result,"Self-test failed")
3022

3123
result=run([venv.python,"-c","import gitdb; import smmap"])
32-
self.assertEqual(
33-
0,
34-
result.returncode,
35-
msg=result.stderrorresult.stdoutor"Dependencies not installed",
36-
)
24+
self._check_result(result,"Dependencies not installed")
3725

3826
# Even IF gitdb or any other dependency is supplied during development by
3927
# inserting its location into PYTHONPATH or otherwise patched into sys.path,
4028
# make sure it is not wrongly inserted as the *first* entry.
4129
result=run([venv.python,"-c","import sys; import git; print(sys.path)"])
42-
syspath=result.stdout.decode("utf-8").splitlines()[0]
30+
syspath=result.stdout.splitlines()[0]
4331
syspath=ast.literal_eval(syspath)
4432
self.assertEqual(
4533
"",
@@ -63,8 +51,17 @@ def _set_up_venv(rw_dir):
6351
run=functools.partial(
6452
subprocess.run,
6553
stdout=subprocess.PIPE,
54+
stderr=subprocess.PIPE,
55+
universal_newlines=True,
6656
cwd=venv.sources,
6757
env={**os.environ,"PYTHONWARNINGS":"error"},
6858
)
6959

7060
returnvenv,run
61+
62+
def_check_result(self,result,failure_summary):
63+
self.assertEqual(
64+
0,
65+
result.returncode,
66+
f"{failure_summary}\nstdout:\n{result.stdout}\nstderr:\n{result.stderr}",
67+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp