amaranth icon indicating copy to clipboard operation
amaranth copied to clipboard

`UnusedElaboratable` message still appearing in `pytest` tests when `xfail(run=False)` marker is used in conjunction with Simulator and warning is suppressed.

Open cr1901 opened this issue 2 years ago • 0 comments

To duplicate:

  1. git clone https://github.com/cr1901/amaranth-unused-elaboratable
  2. pdm install
  3. pdm run test

Output on my Windows machine is the following:

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/amaranth-unused
$ pdm run test
======================================================== test session starts ========================================================= platform win32 -- Python 3.11.5, pytest-7.4.1, pluggy-1.3.0
rootdir: C:/msys64/home/William/Projects/MCVE/amaranth-unused
configfile: pyproject.toml
collected 2 items

tests/test_bar.py x                                                                                                             [ 50%] tests/test_foo.py .                                                                                                             [100%]

==================================================== 1 passed, 1 xfailed in 0.19s ==================================================== C:/msys64/home/William/Projects/MCVE/amaranth-unused/src/amaranth_template_fpga/bar.py:8: UnusedElaboratable: <amaranth_template_fpga.f

oo.Foo object at 0x000002af31f85310> created but never used

Test files have magic comment to suppress that warning:

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/amaranth-unused
$ grep Unused -R src/ tests/
tests/conftest.py:# amaranth: UnusedElaboratable=no
tests/test_bar.py:# amaranth: UnusedElaboratable=no
tests/test_bar.py:@pytest.mark.xfail(run=False)  # Comment to quash UnusedElaboratable warning.
tests/test_foo.py:# amaranth: UnusedElaboratable=no

Confirmed to also have the same message on Ubuntu 20.04 Linux w/ Python 3.8 as well. Commenting out line 9 of either test file causes the warning to disappear.

cr1901 avatar Oct 04 '23 19:10 cr1901