From fa00841df6c4df9acbe666dac2fcc1973aee48e7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 14 Mar 2020 18:56:04 +0100 Subject: [PATCH] tests & travis --- .travis.yml | 8 +++++--- requirements.txt | 3 +++ sample.py | 13 +++++++++++++ setup.py | 3 +-- test_sample.py | 29 +++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 requirements.txt create mode 100644 sample.py create mode 100644 test_sample.py diff --git a/.travis.yml b/.travis.yml index 7231d7e..4a8ad61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: python -python: - - "3.6" -install: pip install . +python: 3.6 +install: + - pip install . + - pip install -r requirements.txt +script: pytest sudo: false \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e4c74fe --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +flask-debug +flask-wtf +pytest \ No newline at end of file diff --git a/sample.py b/sample.py new file mode 100644 index 0000000..e55e667 --- /dev/null +++ b/sample.py @@ -0,0 +1,13 @@ +from flask import Flask +from .flask_semanticui import SemanticUI + + +def create_app(): + app = Flask(__name__) + SemanticUI(app) + + @app.route('/') + def hello(): + return 'Hello, World!' + + return app \ No newline at end of file diff --git a/setup.py b/setup.py index d823c4e..0c74508 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,6 @@ setup( packages=['flask_semanticui'], include_package_data=True, install_requires=[ - 'Flask>=1.0', - 'flask_wtf>=0.14' + 'Flask>=1.0' ] ) diff --git a/test_sample.py b/test_sample.py new file mode 100644 index 0000000..0b4a992 --- /dev/null +++ b/test_sample.py @@ -0,0 +1,29 @@ +import pytest + + +@pytest.fixture +def app(): + import sys + sys.path.append('.') + + from sample import create_app + + app = create_app() + app.debug = True + app.testing = True + + # manually add flask-debug + from flask_debug import Debug + Debug(app) + + return app + + +@pytest.fixture +def client(app): + return app.test_client() + + +def test_index(client): + resp = client.get('/') + assert resp.status_code == 200