Repository: networkx/networkx

Issue:
Update tests for macOS v14
`macos-latest` has switched from macOS v12 to macOS v14:
https://github.com/actions/runner-images/tree/main

Discussion:

Patch:
diff --git a/doc/developer/about_us.rst b/doc/developer/about_us.rst
index 20ac85167..e9e41adf2 100644
--- a/doc/developer/about_us.rst
+++ b/doc/developer/about_us.rst
@@ -153,6 +153,7 @@ to add your name to the bottom of the list.
 - Sebastiano Vigna, Github: `https://github.com/vigna`
 - Aaron Zolnai-Lucas, GitHub: `aaronzo <https://github.com/aaronzo>`_, LinkedIn: `aaronzolnailucas <https://www.linkedin.com/in/aaronzolnailucas/>`_
 - Erik Welch, GitHub: `eriknw <https://github.com/eriknw>`_, LinkedIn: `eriknwelch <https://www.linkedin.com/in/eriknwelch/>`_
+- Mohamed Rezk, Github: `mohamedrezk122 <https://github.com/mohamedrezk122>`_
 
 A supplementary (but still incomplete) list of contributors is given by the
 list of names that have commits in ``networkx``'s
diff --git a/networkx/algorithms/non_randomness.py b/networkx/algorithms/non_randomness.py
index 85483d330..dcfb62cc4 100644
--- a/networkx/algorithms/non_randomness.py
+++ b/networkx/algorithms/non_randomness.py
@@ -51,7 +51,7 @@ def non_randomness(G, k=None, weight="weight"):
     NetworkXException
         if the input graph is not connected.
     NetworkXError
-        if the input graph contains self-loops.
+        if the input graph contains self-loops or if graph has no edges.
 
     Examples
     --------
@@ -74,6 +74,9 @@ def non_randomness(G, k=None, weight="weight"):
     """
     import numpy as np
 
+    # corner case: graph has no edges
+    if nx.is_empty(G):
+        raise nx.NetworkXError("non_randomness not applicable to empty graphs")
     if not nx.is_connected(G):
         raise nx.NetworkXException("Non connected graph.")
     if len(list(nx.selfloop_edges(G))) > 0:


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index c4440fc7f..3d61223db 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -143,7 +143,11 @@ jobs:
         run: |
           pip install --upgrade pip
           pip install -r requirements/default.txt -r requirements/test.txt
-          pip install --global-option=build_ext --global-option="-I/usr/local/include/" --global-option="-L/usr/local/lib/" pygraphviz
+          pip install --no-cache-dir \
+                      --config-settings="--global-option=build_ext" \
+                      --config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
+                      --config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
+                      pygraphviz
           pip install -r requirements/extra.txt
           pip install .
           pip list
diff --git a/networkx/algorithms/tests/test_non_randomness.py b/networkx/algorithms/tests/test_non_randomness.py
index 1f6de597e..2f495be28 100644
--- a/networkx/algorithms/tests/test_non_randomness.py
+++ b/networkx/algorithms/tests/test_non_randomness.py
@@ -22,10 +22,9 @@ def test_non_randomness(k, weight, expected):
 
 
 def test_non_connected():
-    G = nx.Graph()
-    G.add_edge(1, 2)
+    G = nx.Graph([(1, 2)])
     G.add_node(3)
-    with pytest.raises(nx.NetworkXException):
+    with pytest.raises(nx.NetworkXException, match="Non connected"):
         nx.non_randomness(G)
 
 
@@ -33,5 +32,11 @@ def test_self_loops():
     G = nx.Graph()
     G.add_edge(1, 2)
     G.add_edge(1, 1)
-    with pytest.raises(nx.NetworkXError):
+    with pytest.raises(nx.NetworkXError, match="Graph must not contain self-loops"):
+        nx.non_randomness(G)
+
+
+def test_empty_graph():
+    G = nx.empty_graph(1)
+    with pytest.raises(nx.NetworkXError, match=".*not applicable to empty graphs"):
         nx.non_randomness(G)