Skip to content

Is there a way to access the pytest global namespace variables in any module without importing pytest to avoid circular dependency? #2346

Closed
@shreyashah

Description

@shreyashah

I have implemented the pytest_namespace() hook with some key value pairs.
one such pair is the script_name or module_name whose value i update using config.option.file_or_dir

I need to access this variable in one of my other module. The way i know to access this is "pytest.script_name". But for this, I need to do "import pytest" which is creating a circular dependency.
Is there any other way of access these global namespace variables or more specifically, a way to access this config.option.file_or_dir value in my custom class method (Note, this custom class is not a class in any plugin). It could be for example my logger module.

Any help is appreciated. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions