diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2022-10-05 19:19:41 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2022-10-05 20:25:18 -0400 |
| commit | 9859d69f471002738a4d679113e2d4fbebf45014 (patch) | |
| tree | 827021055329b17c0ba39dcc5d34a424e3dfa6fe /setuptools | |
| parent | 1546d40ae9cc26a3fa998d174984cda3ebbae4dd (diff) | |
| download | python-setuptools-git-9859d69f471002738a4d679113e2d4fbebf45014.tar.gz | |
Support caplog and capsys now that logs go through logging.
Diffstat (limited to 'setuptools')
| -rw-r--r-- | setuptools/tests/test_build_ext.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/setuptools/tests/test_build_ext.py b/setuptools/tests/test_build_ext.py index 92ce80ef..62ba925e 100644 --- a/setuptools/tests/test_build_ext.py +++ b/setuptools/tests/test_build_ext.py @@ -194,16 +194,26 @@ class TestBuildExtInplace: cmd.ensure_finalized() return cmd - def test_optional(self, tmpdir_cwd, capsys): + def get_log_messages(self, caplog, capsys): + """ + Historically, distutils "logged" by printing to sys.std*. + Later versions adopted the logging framework. Grab + messages regardless of how they were captured. + """ + std = capsys.readouterr() + return std.out.splitlines() + std.err.splitlines() + caplog.messages + + def test_optional(self, tmpdir_cwd, caplog, capsys): """ If optional extensions fail to build, setuptools should show the error in the logs but not fail to build """ cmd = self.get_build_ext_cmd(optional=True, inplace=True) cmd.run() - logs = capsys.readouterr() - messages = (logs.out + logs.err) - assert 'build_ext: building extension "spam.eggs" failed' in messages + assert any( + 'build_ext: building extension "spam.eggs" failed' + for msg in self.get_log_messages(caplog, capsys) + ) # No compile error exception should be raised def test_non_optional(self, tmpdir_cwd): |
