Repository: jupyter/nbgrader

Issue:
Disable Assignment List extension on Windows
See https://github.com/conda-forge/nbgrader-feedstock/issues/12

@lgpage 

Discussion:

Patch:
diff --git a/nbgrader/__init__.py b/nbgrader/__init__.py
index 7e68cab9..e7ecd231 100644
--- a/nbgrader/__init__.py
+++ b/nbgrader/__init__.py
@@ -3,17 +3,12 @@ A system for assigning and grading notebooks.
 """
 
 import os
+import sys
 from ._version import version_info, __version__
 
 
 def _jupyter_nbextension_paths():
-    return [
-        dict(
-            section="tree",
-            src=os.path.join('nbextensions', 'assignment_list'),
-            dest="assignment_list",
-            require="assignment_list/main"
-        ),
+    paths = [
         dict(
             section="notebook",
             src=os.path.join('nbextensions', 'create_assignment'),
@@ -34,9 +29,26 @@ def _jupyter_nbextension_paths():
         ),
     ]
 
+    if sys.platform != 'win32':
+        paths.append(
+            dict(
+                section="tree",
+                src=os.path.join('nbextensions', 'assignment_list'),
+                dest="assignment_list",
+                require="assignment_list/main"
+            )
+        )
+
+    return paths
+
+
 def _jupyter_server_extension_paths():
-    return [
-        dict(module="nbgrader.server_extensions.assignment_list"),
+    paths = [
         dict(module="nbgrader.server_extensions.formgrader"),
         dict(module="nbgrader.server_extensions.validate_assignment")
     ]
+
+    if sys.platform != 'win32':
+        paths.append(dict(module="nbgrader.server_extensions.assignment_list"))
+
+    return paths


Test patch:
diff --git a/nbgrader/tests/apps/test_nbgrader_extension.py b/nbgrader/tests/apps/test_nbgrader_extension.py
index f0c75f3d..c636413a 100644
--- a/nbgrader/tests/apps/test_nbgrader_extension.py
+++ b/nbgrader/tests/apps/test_nbgrader_extension.py
@@ -1,25 +1,82 @@
 import os
-
 import nbgrader
+import sys
+import contextlib
+
+
+@contextlib.contextmanager
+def mock_platform(platform):
+    old_platform = sys.platform
+    sys.platform = platform
+    yield
+    sys.platform = old_platform
+
+
+def test_nbextension_linux():
+    from nbgrader import _jupyter_nbextension_paths
+    with mock_platform("linux"):
+        nbexts = _jupyter_nbextension_paths()
+        assert len(nbexts) == 4
+        assert nbexts[0]['section'] == 'notebook'
+        assert nbexts[1]['section'] == 'tree'
+        assert nbexts[2]['section'] == 'notebook'
+        assert nbexts[3]['section'] == 'tree'
+        paths = [ext['src'] for ext in nbexts]
+        for path in paths:
+            assert os.path.isdir(os.path.join(os.path.dirname(nbgrader.__file__), path))
+
+
+def test_nbextension_mac():
+    from nbgrader import _jupyter_nbextension_paths
+    with mock_platform("darwin"):
+        nbexts = _jupyter_nbextension_paths()
+        assert len(nbexts) == 4
+        assert nbexts[0]['section'] == 'notebook'
+        assert nbexts[1]['section'] == 'tree'
+        assert nbexts[2]['section'] == 'notebook'
+        assert nbexts[3]['section'] == 'tree'
+        paths = [ext['src'] for ext in nbexts]
+        for path in paths:
+            assert os.path.isdir(os.path.join(os.path.dirname(nbgrader.__file__), path))
 
 
-def test_nbextension():
+def test_nbextension_windows():
     from nbgrader import _jupyter_nbextension_paths
-    nbexts = _jupyter_nbextension_paths()
-    assert len(nbexts) == 4
-    assert nbexts[0]['section'] == 'tree'
-    assert nbexts[1]['section'] == 'notebook'
-    assert nbexts[2]['section'] == 'tree'
-    assert nbexts[3]['section'] == 'notebook'
-    paths = [ext['src'] for ext in nbexts]
-    for path in paths:
-        assert os.path.isdir(os.path.join(os.path.dirname(nbgrader.__file__), path))
-
-
-def test_serverextension():
+    with mock_platform("win32"):
+        nbexts = _jupyter_nbextension_paths()
+        assert len(nbexts) == 3
+        assert nbexts[0]['section'] == 'notebook'
+        assert nbexts[1]['section'] == 'tree'
+        assert nbexts[2]['section'] == 'notebook'
+        paths = [ext['src'] for ext in nbexts]
+        for path in paths:
+            assert os.path.isdir(os.path.join(os.path.dirname(nbgrader.__file__), path))
+
+
+def test_serverextension_linux():
+    from nbgrader import _jupyter_server_extension_paths
+    with mock_platform("linux"):
+        serverexts = _jupyter_server_extension_paths()
+        assert len(serverexts) == 3
+        assert serverexts[0]['module'] == 'nbgrader.server_extensions.formgrader'
+        assert serverexts[1]['module'] == 'nbgrader.server_extensions.validate_assignment'
+        assert serverexts[2]['module'] == 'nbgrader.server_extensions.assignment_list'
+
+
+def test_serverextension_mac():
+    from nbgrader import _jupyter_server_extension_paths
+    with mock_platform("darwin"):
+        serverexts = _jupyter_server_extension_paths()
+        assert len(serverexts) == 3
+        assert serverexts[0]['module'] == 'nbgrader.server_extensions.formgrader'
+        assert serverexts[1]['module'] == 'nbgrader.server_extensions.validate_assignment'
+        assert serverexts[2]['module'] == 'nbgrader.server_extensions.assignment_list'
+
+
+def test_serverextension_windows():
     from nbgrader import _jupyter_server_extension_paths
-    serverexts = _jupyter_server_extension_paths()
-    assert len(serverexts) == 3
-    assert serverexts[0]['module'] == 'nbgrader.server_extensions.assignment_list'
-    assert serverexts[1]['module'] == 'nbgrader.server_extensions.formgrader'
-    assert serverexts[2]['module'] == 'nbgrader.server_extensions.validate_assignment'
+    with mock_platform("win32"):
+        serverexts = _jupyter_server_extension_paths()
+        assert len(serverexts) == 2
+        assert serverexts[0]['module'] == 'nbgrader.server_extensions.formgrader'
+        assert serverexts[1]['module'] == 'nbgrader.server_extensions.validate_assignment'