[dev-gnome-web] manage: Add test command
- From: Lasse Schuirmann <lschuirma src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dev-gnome-web] manage: Add test command
- Date: Thu, 28 Jan 2016 11:21:03 +0000 (UTC)
commit ca019606050cffbfa2a44aab420a6da8fc23acff
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date: Thu Jan 28 12:20:36 2016 +0100
manage: Add test command
manage.py | 22 +++++++++++++++++++++-
server/config.py | 4 ++++
2 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/manage.py b/manage.py
index 45fa939..ef68f33 100755
--- a/manage.py
+++ b/manage.py
@@ -4,7 +4,9 @@
This is an application management application that allows to run the server.
"""
-from subprocess import call
+from os import environ
+from subprocess import Popen, call
+from sys import executable
from flask_script import Manager
@@ -14,6 +16,24 @@ manager = Manager(app)
@manager.command
+def test():
+ """
+ Runs all tests. While doing so, it configures the app to run with the
+ TESTING property enabled:
+
+ >>> app.config['TESTING']
+ True
+
+ :return: 0 if all tests pass.
+ """
+ test_environ = dict(environ)
+ test_environ['FLASK_DB'] = 'sqlite:///test.db'
+ test_environ['FLASK_TESTING'] = 'True'
+ proc = Popen([executable, '-m', 'pytest'], env=test_environ)
+ return proc.wait()
+
+
+ manager command
def coala(noninteractive=False):
"""
Runs code analysis on the application.
diff --git a/server/config.py b/server/config.py
index 5e8ef1a..a6c376c 100644
--- a/server/config.py
+++ b/server/config.py
@@ -2,6 +2,10 @@
This file contains configuration options for the server side application.
"""
+from os import environ
+
BABEL_DEFAULT_LOCALE = 'en'
BABEL_DEFAULT_TIMEZONE = 'UTC'
LANGUAGES = {'en'}
+
+TESTING = environ.get("FLASK_TESTING") is not None
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]