diff --git a/.gitignore b/.gitignore
index ed941bd..95a0451 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.egg-info
__pycache__
+.pytest_cache
.cache
diff --git a/README.md b/README.md
index 84fbeb5..06b5f1d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-# pytest-flask-sqlalchemy-transactions
+# pytest-flask-sqlalchemy
-[![Build Status](https://travis-ci.org/jeancochrane/pytest-flask-sqlalchemy-transactions.svg?branch=master)](https://travis-ci.org/jeancochrane/pytest-flask-sqlalchemy-transactions) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Django.svg)
+[![Build Status](https://travis-ci.org/jeancochrane/pytest-flask-sqlalchemy.svg?branch=master)](https://travis-ci.org/jeancochrane/pytest-flask-sqlalchemy) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Django.svg)
A [pytest](https://docs.pytest.org/en/latest/) plugin providing fixtures for running tests in
transactions using [Flask-SQLAlchemy](http://flask-sqlalchemy.pocoo.org/latest/).
@@ -13,6 +13,7 @@ transactions using [Flask-SQLAlchemy](http://flask-sqlalchemy.pocoo.org/latest/)
- [Installation](#installation)
- [From PyPi](#from-pypi)
- [Development version](#development-version)
+ - [Supported backends](#supported-backends)
- [Configuration](#configuration)
- [Conftest setup](#conftest-setup)
- [Test configuration](#test-configuration)
@@ -125,7 +126,7 @@ def test_transaction_doesnt_persist(db_session):
Install using pip:
```
-pip install pytest-flask-sqlalchemy-transactions
+pip install pytest-flask-sqlalchemy
```
Once installed, pytest will detect the plugin automatically during test collection.
@@ -137,8 +138,8 @@ documentation](https://docs.pytest.org/en/latest/plugins.html?highlight=plugins)
Clone the repo from GitHub and switch into the new directory:
```
-git clone git@github.com:jeancochrane/pytest-flask-sqlalchemy-transactions.git
-cd pytest-flask-sqlalchemy-transactions
+git clone git@github.com:jeancochrane/pytest-flask-sqlalchemy.git
+cd pytest-flask-sqlalchemy
```
You can install using pip:
@@ -147,6 +148,20 @@ You can install using pip:
pip install .
```
+### Supported backends
+
+So far, pytest-flask-sqlalchemy has been most extensively tested against
+PostgreSQL 9.6. It should theoretically work with any backend that is supported
+by SQLAlchemy, but Postgres is the only backend that is currently tested by the
+test suite.
+
+Official support for SQLite and MySQL is [planned for a future
+release](https://github.com/jeancochrane/pytest-flask-sqlalchemy/issues/3).
+In the meantime, if you're using one of those backends and you run in to
+problems, we would greatly appreciate your help! [Open an
+issue](https://github.com/jeancochrane/pytest-flask-sqlalchemy/issues/new) if
+something isn't working as you expect.
+
## Configuration
### Conftest setup
@@ -448,6 +463,10 @@ whose blog post ["Delightful testing with pytest and
Flask-SQLAlchemy"](http://alexmic.net/flask-sqlalchemy-pytest/) helped
establish the basic approach on which this plugin builds.
+Many thanks to [Igor Ghisi](https://github.com/igortg/), who donated the PyPi
+package name. Igor had been working on a similar plugin and proposed combining
+efforts. Thanks to Igor, the plugin name is much stronger.
+
## Copyright
Copyright (c) 2018 Jean Cochrane and DataMade. Released under the MIT License.
diff --git a/transactions/__init__.py b/pytest_flask_sqlalchemy/__init__.py
similarity index 100%
rename from transactions/__init__.py
rename to pytest_flask_sqlalchemy/__init__.py
diff --git a/transactions/fixtures.py b/pytest_flask_sqlalchemy/fixtures.py
similarity index 98%
rename from transactions/fixtures.py
rename to pytest_flask_sqlalchemy/fixtures.py
index 972a810..7d44ac8 100644
--- a/transactions/fixtures.py
+++ b/pytest_flask_sqlalchemy/fixtures.py
@@ -12,11 +12,11 @@ def _db():
Session object that can access the test database. If the user hasn't defined
that fixture, raise an error.
'''
- msg = ("_db fixture not defined. The pytest-flask-sqlalchemy-transactions plugin " +
- "requires you to define a _db fixture that returns a SQLAlchemy session " +
+ msg = ("_db fixture not defined. The pytest-flask-sqlalchemy plugin " +
+ "requires you to define a _db fixture that returns a SQLAlchemy Session " +
"with access to your test database. For more information, see the plugin " +
"documentation: " +
- "https://github.com/jeancochrane/pytest-flask-sqlalchemy-transactions#conftest-setup")
+ "https://github.com/jeancochrane/pytest-flask-sqlalchemy#conftest-setup")
raise NotImplementedError(msg)
diff --git a/transactions/plugin.py b/pytest_flask_sqlalchemy/plugin.py
similarity index 100%
rename from transactions/plugin.py
rename to pytest_flask_sqlalchemy/plugin.py
diff --git a/setup.py b/setup.py
index d2c7524..aff550c 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,3 @@
-'''
-pytest-flask-sqlalchemy-transactions
-====================================
-
-Run tests in transactions using pytest, Flask, and SQLAlchemy.
-'''
from setuptools import setup
@@ -12,16 +6,16 @@ def readme():
return f.read()
setup(
- name='pytest-flask-sqlalchemy-transactions',
+ name='pytest-flask-sqlalchemy',
author='Jean Cochrane',
author_email='jean@jeancochrane.com',
- url='https://github.com/jeancochrane/pytest-flask-sqlalchemy-transactions',
- description='Run tests in transactions using pytest, Flask, and SQLalchemy.',
+ url='https://github.com/jeancochrane/pytest-flask-sqlalchemy',
+ description='A pytest plugin for preserving test isolation in Flask-SQlAlchemy using database transactions.',
long_description=readme(),
long_description_content_type='text/markdown',
license='MIT',
- version='1.0.1',
- packages=['transactions'],
+ version='1.0.0',
+ packages=['pytest_flask_sqlalchemy'],
install_requires=['pytest>=3.2.1',
'pytest-mock>=1.6.2',
'SQLAlchemy>=1.2.2',
@@ -42,7 +36,7 @@ def readme():
# Make the package available to pytest
entry_points={
'pytest11': [
- 'pytest-flask-sqlalchemy-transactions = transactions.plugin',
+ 'pytest-flask-sqlalchemy = pytest_flask_sqlalchemy.plugin',
]
},
)
diff --git a/tests/_conftest.py b/tests/_conftest.py
index 23f688f..ded4acb 100644
--- a/tests/_conftest.py
+++ b/tests/_conftest.py
@@ -19,7 +19,7 @@
else:
DB_OPTS = sa.engine.url.make_url(DB_CONN).translate_connect_args()
-pytest_plugins = ['pytest-flask-sqlalchemy-transactions']
+pytest_plugins = ['pytest-flask-sqlalchemy']
@pytest.fixture(scope='session')
diff --git a/tests/conftest.py b/tests/conftest.py
index 4e611ab..462d09d 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,3 +1,5 @@
+import os
+
import pytest
# This import prevents SQLAlchemy from throwing an AttributeError
@@ -14,7 +16,7 @@ def conftest():
Load configuration file for the tests to a string, in order to run it in
its own temporary directory.
'''
- with open('tests/_conftest.py', 'r') as conf:
+ with open(os.path.join('tests', '_conftest.py'), 'r') as conf:
conftest = conf.read()
return conftest
diff --git a/tests/test_configs.py b/tests/test_configs.py
index e10adf1..1289784 100644
--- a/tests/test_configs.py
+++ b/tests/test_configs.py
@@ -53,8 +53,8 @@ def test_mocked_sessionmakers(db_testdir):
db_testdir.makepyfile("""
def test_mocked_sessionmakers(db_session):
from collections import namedtuple, Counter
- assert str(namedtuple).startswith(".FakeSessionMaker")
- assert str(Counter).startswith(".FakeSessionMaker")
+ assert str(namedtuple).startswith(".FakeSessionMaker")
+ assert str(Counter).startswith(".FakeSessionMaker")
""")
result = db_testdir.runpytest()
@@ -88,7 +88,7 @@ def test_missing_db_fixture(testdir):
else:
DB_OPTS = sa.engine.url.make_url(DB_CONN).translate_connect_args()
- pytest_plugins = ['pytest-flask-sqlalchemy-transactions']
+ pytest_plugins = ['pytest-flask-sqlalchemy']
@pytest.fixture(scope='session')