^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E AttributeError: 'NoneType' object has no attribute 'add_real_directory'
tests/fetcher/test_http_artifact_fetcher.py:100: AttributeError
___________________ test_scan[dummy_py_project_01-expected0] ___________________
[gw0] linux -- Python 3.11.13 $PREFIX/bin/python
project_name = 'dummy_py_project_01'
expected = {ProjectDependency(data=MatchSpec("python"), type=<DependencySection.RUN: 3>), ProjectDependency(data=MatchSpec("conda... type=<DependencySection.RUN: 3>), ProjectDependency(data=MatchSpec("requests"), type=<DependencySection.RUN: 3>), ...}
request = <FixtureRequest for <Function test_scan[dummy_py_project_01-expected0]>>
@pytest.mark.parametrize(
"project_name,expected",
[
(
"dummy_py_project_01",
{
ProjectDependency(MatchSpec("conda_recipe_manager"), DependencySection.RUN),
ProjectDependency(MatchSpec("matplotlib"), DependencySection.RUN), # Two imports on one line
ProjectDependency(MatchSpec("networkx"), DependencySection.RUN), # Two imports on one line
ProjectDependency(MatchSpec("python"), DependencySection.HOST),
ProjectDependency(MatchSpec("python"), DependencySection.RUN),
ProjectDependency(MatchSpec("pyyaml"), DependencySection.TESTS),
ProjectDependency(MatchSpec("requests"), DependencySection.RUN), # Found in source and test code.
},
),
],
)
def test_scan(project_name: str, expected: set[ProjectDependency], request: pytest.FixtureRequest) -> None:
"""
Tests scanning for Python dependencies with a mocked-out Python project.
:param project_name: Name of the dummy Python project directory to use
:param expected: Expected value
"""
fs = cast(FakeFilesystem, request.getfixturevalue("fs"))
project_path: Final[Path] = get_test_path() / "software_projects" / project_name
> fs.add_real_directory(project_path)
^^^^^^^^^^^^^^^^^^^^^
E AttributeError: 'NoneType' object has no attribute 'add_real_directory'
This came up in this comment by @schuylermartin45:
While examining the log file from the test, I found the following part:
I'm not sure if this is the root of the problem, but it looks like the modules change while iterating over them - probably some module behaving unexpectedly, but this should be avoided, maybe by making a copy of the modules before iterating over them (have to check the performance impact).
A related problem (#338) had been reported (and fixed) quite some time ago, though I have never seen this specific problem until now.