about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2020-08-30 12:59:12 +0200
committerFrederik Rietdijk <fridh@fridh.nl>2020-08-30 12:59:24 +0200
commit5d8dd5c2598a74761411bc9bef7c9111d43d2429 (patch)
treed1cec3ac9ba561881a032efb777d3d1b46e0c4f0 /pkgs
parent0610e03496744b3ce6f52a665aad117fb53b8571 (diff)
python.tests: don't mix the two types of tests
The integration tests code was included in the environment tests. After
this commit it is hopefully clearer what belongs together.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/interpreters/python/tests.nix145
-rw-r--r--pkgs/development/interpreters/python/tests/test_environments/test_python.py (renamed from pkgs/development/interpreters/python/tests/test_python.py)0
2 files changed, 75 insertions, 70 deletions
diff --git a/pkgs/development/interpreters/python/tests.nix b/pkgs/development/interpreters/python/tests.nix
index 03a3b95370901..dcfa41cc308e2 100644
--- a/pkgs/development/interpreters/python/tests.nix
+++ b/pkgs/development/interpreters/python/tests.nix
@@ -6,67 +6,81 @@
 }:
 
 let
-  envs = let
-    inherit python;
-    pythonEnv = python.withPackages(ps: with ps; [ ]);
-    pythonVirtualEnv = python.withPackages(ps: with ps; [ virtualenv ]);
-  in {
-    # Plain Python interpreter
-    plain = rec {
-      env = python;
-      interpreter = env.interpreter;
-      is_venv = "False";
-      is_nixenv = "False";
-      is_virtualenv = "False";
-    };
-  } // lib.optionalAttrs (!python.isPyPy) {
-    # Use virtualenv from a Nix env.
-    nixenv-virtualenv = rec {
-      env = runCommand "${python.name}-virtualenv" {} ''
-        ${pythonVirtualEnv.interpreter} -m virtualenv $out
-      '';
-      interpreter = "${env}/bin/${python.executable}";
-      is_venv = "False";
-      is_nixenv = "True";
-      is_virtualenv = "True";
-    };
-  } // lib.optionalAttrs (python.implementation != "graal") {
-    # Python Nix environment (python.buildEnv)
-    nixenv = rec {
-      env = pythonEnv;
-      interpreter = env.interpreter;
-      is_venv = "False";
-      is_nixenv = "True";
-      is_virtualenv = "False";
-    };
-  } // lib.optionalAttrs (python.isPy3k && (!python.isPyPy)) rec {
-    # Venv built using plain Python
-    # Python 2 does not support venv
-    # TODO: PyPy executable name is incorrect, it should be pypy-c or pypy-3c instead of pypy and pypy3.
-    plain-venv = rec {
-      env = runCommand "${python.name}-venv" {} ''
-        ${python.interpreter} -m venv $out
-      '';
-      interpreter = "${env}/bin/${python.executable}";
-      is_venv = "True";
-      is_nixenv = "False";
-      is_virtualenv = "False";
-    };
+  environmentTests = let
+    envs = let
+      inherit python;
+      pythonEnv = python.withPackages(ps: with ps; [ ]);
+      pythonVirtualEnv = python.withPackages(ps: with ps; [ virtualenv ]);
+    in {
+      # Plain Python interpreter
+      plain = rec {
+        env = python;
+        interpreter = env.interpreter;
+        is_venv = "False";
+        is_nixenv = "False";
+        is_virtualenv = "False";
+      };
+    } // lib.optionalAttrs (!python.isPyPy) {
+      # Use virtualenv from a Nix env.
+      nixenv-virtualenv = rec {
+        env = runCommand "${python.name}-virtualenv" {} ''
+          ${pythonVirtualEnv.interpreter} -m virtualenv $out
+        '';
+        interpreter = "${env}/bin/${python.executable}";
+        is_venv = "False";
+        is_nixenv = "True";
+        is_virtualenv = "True";
+      };
+    } // lib.optionalAttrs (python.implementation != "graal") {
+      # Python Nix environment (python.buildEnv)
+      nixenv = rec {
+        env = pythonEnv;
+        interpreter = env.interpreter;
+        is_venv = "False";
+        is_nixenv = "True";
+        is_virtualenv = "False";
+      };
+    } // lib.optionalAttrs (python.isPy3k && (!python.isPyPy)) rec {
+      # Venv built using plain Python
+      # Python 2 does not support venv
+      # TODO: PyPy executable name is incorrect, it should be pypy-c or pypy-3c instead of pypy and pypy3.
+      plain-venv = rec {
+        env = runCommand "${python.name}-venv" {} ''
+          ${python.interpreter} -m venv $out
+        '';
+        interpreter = "${env}/bin/${python.executable}";
+        is_venv = "True";
+        is_nixenv = "False";
+        is_virtualenv = "False";
+      };
 
-  } // lib.optionalAttrs (python.pythonAtLeast "3.8") {
-    # Venv built using Python Nix environment (python.buildEnv)
-    # TODO: Cannot create venv from a  nix env
-    # Error: Command '['/nix/store/ddc8nqx73pda86ibvhzdmvdsqmwnbjf7-python3-3.7.6-venv/bin/python3.7', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
-    nixenv-venv = rec {
-      env = runCommand "${python.name}-venv" {} ''
-        ${pythonEnv.interpreter} -m venv $out
-      '';
-      interpreter = "${env}/bin/${pythonEnv.executable}";
-      is_venv = "True";
-      is_nixenv = "True";
-      is_virtualenv = "False";
+    } // lib.optionalAttrs (python.pythonAtLeast "3.8") {
+      # Venv built using Python Nix environment (python.buildEnv)
+      # TODO: Cannot create venv from a  nix env
+      # Error: Command '['/nix/store/ddc8nqx73pda86ibvhzdmvdsqmwnbjf7-python3-3.7.6-venv/bin/python3.7', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
+      nixenv-venv = rec {
+        env = runCommand "${python.name}-venv" {} ''
+          ${pythonEnv.interpreter} -m venv $out
+        '';
+        interpreter = "${env}/bin/${pythonEnv.executable}";
+        is_venv = "True";
+        is_nixenv = "True";
+        is_virtualenv = "False";
+      };
     };
-  };
+
+    testfun = name: attrs: runCommand "${python.name}-tests-${name}" ({
+      inherit (python) pythonVersion;
+    } // attrs) ''
+      cp -r ${./tests/test_environments} tests
+      chmod -R +w tests
+      substituteAllInPlace tests/test_python.py
+      ${attrs.interpreter} -m unittest discover --verbose tests #/test_python.py
+      mkdir $out
+      touch $out/success
+    '';
+
+  in lib.mapAttrs testfun envs;
 
   # All PyPy package builds are broken at the moment
   integrationTests = lib.optionalAttrs (python.pythonAtLeast "3.7"  && (!python.isPyPy)) rec {
@@ -76,15 +90,6 @@ let
     };
   };
 
-  testfun = name: attrs: runCommand "${python.name}-tests-${name}" ({
-    inherit (python) pythonVersion;
-  } // attrs) ''
-    cp -r ${./tests} tests
-    chmod -R +w tests
-    substituteAllInPlace tests/test_python.py
-    ${attrs.interpreter} -m unittest discover --verbose tests #/test_python.py
-    mkdir $out
-    touch $out/success
-  '';
 
-in lib.mapAttrs testfun envs // integrationTests
+
+in environmentTests // integrationTests
diff --git a/pkgs/development/interpreters/python/tests/test_python.py b/pkgs/development/interpreters/python/tests/test_environments/test_python.py
index 0fc4b8a9e91c1..0fc4b8a9e91c1 100644
--- a/pkgs/development/interpreters/python/tests/test_python.py
+++ b/pkgs/development/interpreters/python/tests/test_environments/test_python.py