From 10a9b37b0408795c426e1206c39417300fb28f1b Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Thu, 13 Jun 2024 13:59:43 -0500 Subject: [PATCH] test: try fix weird issue --- tests/test_compiler.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_compiler.py b/tests/test_compiler.py index 782dfe4..0e10b65 100644 --- a/tests/test_compiler.py +++ b/tests/test_compiler.py @@ -9,6 +9,7 @@ from ethpm_types import ContractType from packaging.version import Version +from ape_solidity.compiler import logger from ape_solidity.exceptions import IndexOutOfBoundsError EXPECTED_NON_SOLIDITY_ERR_MSG = "Unable to compile 'RandomVyperFile.vy' using Solidity compiler." @@ -690,8 +691,17 @@ def test_enrich_error_when_builtin(project, owner, connection): def test_flatten(project, compiler, caplog): path = project.sources.lookup("contracts/Imports.sol") with caplog.at_level(LogLevel.WARNING): - compiler.flatten_contract(path, project=project) - actual = caplog.messages[-1] + res = compiler.flatten_contract(path, project=project) + + # Ensure logger was flushed. + for handler in logger._logger.handlers: + handler.flush() + + messages = caplog.messages + if len(messages) == 0: + pytest.fail(f"Missing captured logs for conflicting license. Result: {res}") + + actual = messages[-1] expected = ( "Conflicting licenses found: 'LGPL-3.0-only, MIT'. " "Using the root file's license 'MIT'."