Description: On single-CPU systems, skip tests which are known not to work
Author: Santiago Vila <sanvila@debian.org>
Origin: https://github.com/pyg-team/pytorch_geometric/commit/68b6fa1d7bfda77676ba506464ff9c488587cc9c
Forwarded: https://github.com/pyg-team/pytorch_geometric/pull/9817
Last-Update: 2025-06-06

Otherwise test_cpu_affinity_neighbor_loader() fails in this way:

E    ValueError: More workers (got 2) than available cores (got 1)

and test_multithreading_neighbor_loader() fails in this way:

E    ValueError: 'worker_threads' should be smaller than the total available number of threads 1 (got 2)

--- a/test/loader/test_mixin.py
+++ b/test/loader/test_mixin.py
@@ -1,6 +1,7 @@
 import subprocess
 from time import sleep
 
+import psutil
 import pytest
 import torch
 
@@ -11,6 +12,8 @@
 
 @onlyLinux
 @onlyNeighborSampler
+@pytest.mark.skipif(
+    psutil.cpu_count(logical=False) == 1, reason="Requires multiple CPU cores")
 @pytest.mark.parametrize('loader_cores', [None, [1, 2]])
 def test_cpu_affinity_neighbor_loader(loader_cores, spawn_context):
     data = Data(x=torch.randn(1, 1))
@@ -40,6 +43,8 @@
 
 @onlyLinux
 @onlyNeighborSampler
+@pytest.mark.skipif(
+    psutil.cpu_count(logical=False) == 1, reason="Requires multiple CPU cores")
 def test_multithreading_neighbor_loader(spawn_context):
     loader = NeighborLoader(
         data=Data(x=torch.randn(1, 1)),
