summaryrefslogtreecommitdiff
blob: 484e816908f47472929dff3df19ce68d0713e4e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From 8943f49c3e6064839bd1e3c2c73a750b2b476ae3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Wed, 15 Jul 2020 09:02:15 +0200
Subject: [PATCH 1/2] tests: Skip tests requiring specific data backends if not
 available

Skip tests that require a specific database backend if the respective
package is not available.  This is mostly intended to make it possible
to test flask-security on Python 3.9 since Pony does not support this
Python version but there is no harm in extending it to other backends.

Technically, Flask-SQLAlchemy is still required due to other tests.
---
 tests/conftest.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/conftest.py b/tests/conftest.py
index 3305d92..a48f480 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -218,6 +218,7 @@ def mongoengine_datastore(request, app, tmpdir, realdburl):
 
 
 def mongoengine_setup(request, app, tmpdir, realdburl):
+    pytest.importorskip('flask_mongoengine')
     from flask_mongoengine import MongoEngine
     from mongoengine.fields import (
         BooleanField,
@@ -282,6 +283,7 @@ def sqlalchemy_datastore(request, app, tmpdir, realdburl):
 
 
 def sqlalchemy_setup(request, app, tmpdir, realdburl):
+    pytest.importorskip('flask_sqlalchemy')
     from flask_sqlalchemy import SQLAlchemy
     from flask_security.models import fsqla_v2 as fsqla
 
@@ -326,6 +328,7 @@ def sqlalchemy_session_datastore(request, app, tmpdir, realdburl):
 
 
 def sqlalchemy_session_setup(request, app, tmpdir, realdburl):
+    pytest.importorskip('sqlalchemy')
     from sqlalchemy import create_engine
     from sqlalchemy.orm import scoped_session, sessionmaker, relationship, backref
     from sqlalchemy.ext.declarative import declarative_base
@@ -426,6 +429,7 @@ def peewee_datastore(request, app, tmpdir, realdburl):
 
 
 def peewee_setup(request, app, tmpdir, realdburl):
+    pytest.importorskip('peewee')
     from peewee import (
         TextField,
         DateTimeField,
@@ -522,6 +526,7 @@ def pony_datastore(request, app, tmpdir, realdburl):
 
 def pony_setup(request, app, tmpdir, realdburl):
 
+    pytest.importorskip('pony')
     from pony.orm import Database, Optional, Required, Set
     from pony.orm.core import SetInstance
 
-- 
2.27.0