From c142b7e4419e61306a94b16b30b3c7cdef14f85a Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Wed, 27 Mar 2024 09:11:50 -0700 Subject: [PATCH] python3Packages.cocotb: fix build I removed the test as it currently fails on master and is removed upstream in the as-yet-unreleased next version. The test that fails looks like this: ``` Traceback (most recent call last): File "/build/source/tests/test_cases/test_cocotb/test_deprecated.py", line 39, in test_unicode_handle_assignment_deprecated dut.stream_in_string.value = "Bad idea" ^^^^^^^^^^^^^^^^^^^^ File "/nix/store/yvcizx3fwkm044jpw9sfpnb0kx0g2bfl-python3.11-cocotb-1.8.1/lib/python3.11/site-packages/cocotb/handle.py", line 370, in __getattr__ raise AttributeError(f"{self._name} contains no object named {name}") AttributeError: sample_module contains no object named stream_in_string During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/build/source/tests/test_cases/test_cocotb/test_deprecated.py", line 38, in test_unicode_handle_assignment_deprecated with pytest.warns(DeprecationWarning, match=".*bytes.*"): File "/nix/store/5ipi1f14ji1nrvqnf8h8fqvr0zny183d-python3.11-pytest-8.0.2/lib/python3.11/site-packages/_pytest/recwarn.py", line 332, in __exit__ fail( File "/nix/store/5ipi1f14ji1nrvqnf8h8fqvr0zny183d-python3.11-pytest-8.0.2/lib/python3.11/site-packages/_pytest/outcomes.py", line 188, in fail raise Failed(msg=reason, pytrace=pytrace) Failed: DID NOT WARN. No warnings of type (,) were emitted. Emitted warnings: []. ``` --- ...de_handle_assignment_deprecated-test.patch | 25 +++++++++++++++++++ .../python-modules/cocotb/default.nix | 4 +++ 2 files changed, 29 insertions(+) create mode 100644 pkgs/development/python-modules/cocotb/0002-Patch-remove-test_unicode_handle_assignment_deprecated-test.patch diff --git a/pkgs/development/python-modules/cocotb/0002-Patch-remove-test_unicode_handle_assignment_deprecated-test.patch b/pkgs/development/python-modules/cocotb/0002-Patch-remove-test_unicode_handle_assignment_deprecated-test.patch new file mode 100644 index 000000000000..f1a6c7f975fa --- /dev/null +++ b/pkgs/development/python-modules/cocotb/0002-Patch-remove-test_unicode_handle_assignment_deprecated-test.patch @@ -0,0 +1,25 @@ +diff --git a/tests/test_cases/test_cocotb/test_deprecated.py b/tests/test_cases/test_cocotb/test_deprecated.py +index 523b93ba..b4f1701e 100644 +--- a/tests/test_cases/test_cocotb/test_deprecated.py ++++ b/tests/test_cases/test_cocotb/test_deprecated.py +@@ -26,20 +26,6 @@ async def test_returnvalue_deprecated(dut): + assert val == 42 + + +-# strings are not supported on Icarus (gh-2585) or GHDL (gh-2584) +-@cocotb.test( +- expect_error=AttributeError +- if cocotb.SIM_NAME.lower().startswith("icarus") +- else TypeError +- if cocotb.SIM_NAME.lower().startswith("ghdl") +- else () +-) +-async def test_unicode_handle_assignment_deprecated(dut): +- with pytest.warns(DeprecationWarning, match=".*bytes.*"): +- dut.stream_in_string.value = "Bad idea" +- await cocotb.triggers.ReadWrite() +- +- + @cocotb.test() + async def test_convert_handle_to_string_deprecated(dut): + dut.stream_in_data.value = 0 diff --git a/pkgs/development/python-modules/cocotb/default.nix b/pkgs/development/python-modules/cocotb/default.nix index 0e758490b803..8d996a4ebb04 100644 --- a/pkgs/development/python-modules/cocotb/default.nix +++ b/pkgs/development/python-modules/cocotb/default.nix @@ -52,6 +52,10 @@ buildPythonPackage rec { patches = [ # Fix "can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file" error ./0001-Patch-LDCXXSHARED-for-macOS-along-with-LDSHARED.patch + + # For the 1.8.1 release only: remove the test_unicode_handle_assignment_deprecated test + # It's more thoroughly removed upstream master with 425e1edb8e7133f4a891f2f87552aa2748cd8d2c + ./0002-Patch-remove-test_unicode_handle_assignment_deprecated-test.patch ]; nativeCheckInputs = [ cocotb-bus pytestCheckHook swig verilog ghdl ];