brotlicffi icon indicating copy to clipboard operation
brotlicffi copied to clipboard

test/conftest.py references nonexistant file

Open apteryks opened this issue 1 year ago • 1 comments

Hi,

https://github.com/python-hyper/brotlicffi/blob/8e27c661a3e18cbc46e1058ecf74fb98aa2e6615/test/conftest.py#L9

TEST_DATA_DIR references a $PWD/libbrotli/tests/testdata directory, which doesn't exist, which breaks pytest execution like:

ImportError while loading conftest '/tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/conftest.py'.
test/conftest.py:11: in <module>
    os.path.join(TEST_DATA_DIR, p) for p in os.listdir(TEST_DATA_DIR)
E   FileNotFoundError: [Errno 2] No such file or directory: '/tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/libbrotli/tests/testdata'

apteryks avatar Dec 02 '24 00:12 apteryks

Passing --noconftest to pytest in turns breaks all the tests using the compressed file fixture, e.g.:

==================================== ERRORS ====================================
___________ ERROR at setup of test_roundtrip_compression_with_files ____________
file /tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_compression.py, line 16
  def test_roundtrip_compression_with_files(simple_compressed_file):
E       fixture 'simple_compressed_file' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_compression.py:16
_________________ ERROR at setup of test_streaming_compression _________________
file /tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_compression.py, line 28
  @pytest.mark.slow
  @settings(deadline=None)
  @given(
      chunk_size=integers(min_value=1, max_value=2**12),
      mode=sampled_from(list(brotlicffi.BrotliEncoderMode)),
      quality=integers(min_value=0, max_value=11),
      lgwin=integers(min_value=10, max_value=24),
      lgblock=one_of(
          integers(min_value=0, max_value=0),
          integers(min_value=16, max_value=24)
      ),
  )
  def test_streaming_compression(one_compressed_file,
E       fixture 'one_compressed_file' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_compression.py:28
______________ ERROR at setup of test_streaming_compression_flush ______________
file /tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_compression.py, line 67
  @pytest.mark.slow
  @settings(deadline=None)
  @given(
      chunk_size=integers(min_value=1, max_value=2**12),
      mode=sampled_from(list(brotlicffi.BrotliEncoderMode)),
      quality=integers(min_value=0, max_value=11),
      lgwin=integers(min_value=10, max_value=24),
      lgblock=one_of(
          integers(min_value=0, max_value=0),
          integers(min_value=16, max_value=24)
      ),
  )
  def test_streaming_compression_flush(one_compressed_file,
E       fixture 'one_compressed_file' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_compression.py:67
_____________________ ERROR at setup of test_decompression _____________________
file /tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_decompression.py, line 13
  def test_decompression(simple_compressed_file):
E       fixture 'simple_compressed_file' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_decompression.py:13
_____________________ ERROR at setup of test_decompressobj _____________________
file /tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_decompression.py, line 26
  def test_decompressobj(simple_compressed_file):
E       fixture 'simple_compressed_file' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_decompression.py:26
_______________________ ERROR at setup of test_drip_feed _______________________
file /tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_decompression.py, line 41
  def test_drip_feed(simple_compressed_file):
E       fixture 'simple_compressed_file' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/tmp/guix-build-python-brotlicffi-1.1.0.0.drv-0/brotlicffi-1.1.0.0/test/test_simple_decompression.py:41
=========================== short test summary info ============================
ERROR test/test_simple_compression.py::test_roundtrip_compression_with_files
ERROR test/test_simple_compression.py::test_streaming_compression
ERROR test/test_simple_compression.py::test_streaming_compression_flush
ERROR test/test_simple_decompression.py::test_decompression
ERROR test/test_simple_decompression.py::test_decompressobj
ERROR test/test_simple_decompression.py::test_drip_feed
================== 13 passed, 1 deselected, 6 errors in 0.39s ==================

A workaround: pytest --noconftest --ignore=test/test_simple_compression.py --ignore=test/test_simple_decompression.py

apteryks avatar Dec 02 '24 00:12 apteryks

If you haven't already figured it out, it looks to me like there's a submodule there. So you probably just failed to fetch the submodule in git.

Dreamsorcerer avatar Oct 15 '25 15:10 Dreamsorcerer

Ah, thanks for pointing that out. Indeed, recursive? defauts to #f in Guix, as that's typically used to fetch 3rd party libraries and we generally prefer to package these separately.

apteryks avatar Oct 15 '25 23:10 apteryks

And it looks like in the meantime someone figured it out in Guix :-). See https://codeberg.org/guix/guix/commit/ebf301e359188a32bfd130a40f6d89b48389b7cd.

apteryks avatar Oct 15 '25 23:10 apteryks