From 4f15d3d28d1397f6cbf97fe8092a739353c10f9e Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Mon, 26 Jun 2017 19:01:15 +0200
Subject: [PATCH] Fixed #19: now uses pytest as a testing framework

---
 .gitlab-ci.yml            | 3 +--
 api/pytest.ini            | 5 +++++
 api/requirements/test.txt | 4 ++++
 api/runtests              | 2 +-
 api/test.yml              | 4 +---
 5 files changed, 12 insertions(+), 6 deletions(-)
 create mode 100644 api/pytest.ini

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 577d8b79..74bc0f7b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,8 +9,7 @@ test_api:
     - cd api
     - pip install -r requirements/test.txt
   script:
-    - export DJANGO_SETTINGS_MODULE=config.settings.test
-    - python manage.py test
+    - pytest
 
   tags:
     - docker
diff --git a/api/pytest.ini b/api/pytest.ini
new file mode 100644
index 00000000..4ab90740
--- /dev/null
+++ b/api/pytest.ini
@@ -0,0 +1,5 @@
+[pytest]
+DJANGO_SETTINGS_MODULE=config.settings.test
+
+# -- recommended but optional:
+python_files = tests.py test_*.py *_tests.py
diff --git a/api/requirements/test.txt b/api/requirements/test.txt
index 93509c57..a26cf5bd 100644
--- a/api/requirements/test.txt
+++ b/api/requirements/test.txt
@@ -5,3 +5,7 @@
 flake8==2.5.0
 model-mommy==1.3.2
 tox==2.7.0
+pytest
+pytest-django
+pytest-sugar
+pytest-xdist
diff --git a/api/runtests b/api/runtests
index bd8db7a8..48e7b826 100755
--- a/api/runtests
+++ b/api/runtests
@@ -2,4 +2,4 @@
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
-docker-compose -f $DIR/test.yml run test python manage.py test "$@"
+docker-compose -f $DIR/test.yml run test pytest "$@"
diff --git a/api/test.yml b/api/test.yml
index dc50a9b5..6215e27d 100644
--- a/api/test.yml
+++ b/api/test.yml
@@ -1,8 +1,6 @@
 test:
   dockerfile: docker/Dockerfile.test
   build: .
-  command: python manage.py test
+  command: pytest
   volumes:
     - .:/app
-  environment:
-    - DJANGO_SETTINGS_MODULE=config.settings.test
-- 
GitLab