Skip to content

Use 'PYTEST_CURRENT_TEST' not in os.environ over 'pytest' not in sys.modules #10463

@akihironitta

Description

@akihironitta

🛠 Proposed Refactor

Use:

- 'pytest' not in sys.modules
+ 'PYTEST_CURRENT_TEST' not in os.environ

Here's the list of occurrences:

$ git grep pytest |grep sys.modules
torch_geometric/data/dataset.py:261:        if self.log and 'pytest' not in sys.modules:
torch_geometric/data/dataset.py:272:        if self.log and 'pytest' not in sys.modules:
torch_geometric/data/download.py:37:        if log and 'pytest' not in sys.modules:
torch_geometric/data/download.py:41:    if log and 'pytest' not in sys.modules:
torch_geometric/data/extract.py:10:    if log and 'pytest' not in sys.modules:
torch_geometric/io/fs.py:120:        if log and 'pytest' not in sys.modules:
torch_geometric/nn/dense/linear.py:265:        MEASURE_ITER = 1 if 'pytest' in sys.modules else 3
torch_geometric/typing.py:51:    if WITH_SEGMM and 'pytest' in sys.modules and torch.cuda.is_available():

Suggest a potential alternative/fix

n/a

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions