diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7a57693e2cc22d9f69b79fa8a63c836770a5ae05..d6d9f153289ad1f27e0d1d009a300fbcf7690d63 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -32,10 +32,19 @@ default:
     - pip install virtualenv
     - virtualenv venv
     - source venv/bin/activate
-    - pip install matplotlib numpy scipy six nose coverage
+    - pip install --upgrade pip
+    - pip install matplotlib numpy scipy six nose coverage pytest pytest-cov
+
+stages:
+  - test
+# Change pip's cache directory to be inside the project directory since we can
+# only cache local items.
+variables:
+  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
 
 install_and_test_39:
   image: python:3.9
+  stage: test
   script:
     - dpkg -L python3-pytest | xargs file | grep executable
     - pip3 install -e . --no-deps