Skip to content

Commit 4283cb8

Browse files
authored
Merge pull request #2 from jeancochrane/rename-plugin
Rename the plugin to 'pytest-flask-sqlalchemy'
2 parents 4f3111e + edf6d84 commit 4283cb8

File tree

9 files changed

+41
-25
lines changed

9 files changed

+41
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.egg-info
22
__pycache__
3+
.pytest_cache
34
.cache

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# pytest-flask-sqlalchemy-transactions
1+
# pytest-flask-sqlalchemy
22

3-
[![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)
3+
[![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)
44

55
A [pytest](https://docs.pytest.org/en/latest/) plugin providing fixtures for running tests in
66
transactions using [Flask-SQLAlchemy](http://flask-sqlalchemy.pocoo.org/latest/).
@@ -13,6 +13,7 @@ transactions using [Flask-SQLAlchemy](http://flask-sqlalchemy.pocoo.org/latest/)
1313
- [Installation](#installation)
1414
- [From PyPi](#from-pypi)
1515
- [Development version](#development-version)
16+
- [Supported backends](#supported-backends)
1617
- [Configuration](#configuration)
1718
- [Conftest setup](#conftest-setup)
1819
- [Test configuration](#test-configuration)
@@ -125,7 +126,7 @@ def test_transaction_doesnt_persist(db_session):
125126
Install using pip:
126127

127128
```
128-
pip install pytest-flask-sqlalchemy-transactions
129+
pip install pytest-flask-sqlalchemy
129130
```
130131

131132
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)
137138
Clone the repo from GitHub and switch into the new directory:
138139

139140
```
140-
git clone [email protected]:jeancochrane/pytest-flask-sqlalchemy-transactions.git
141-
cd pytest-flask-sqlalchemy-transactions
141+
git clone [email protected]:jeancochrane/pytest-flask-sqlalchemy.git
142+
cd pytest-flask-sqlalchemy
142143
```
143144

144145
You can install using pip:
@@ -147,6 +148,20 @@ You can install using pip:
147148
pip install .
148149
```
149150

151+
### <a name="supported-backends">Supported backends</a>
152+
153+
So far, pytest-flask-sqlalchemy has been most extensively tested against
154+
PostgreSQL 9.6. It should theoretically work with any backend that is supported
155+
by SQLAlchemy, but Postgres is the only backend that is currently tested by the
156+
test suite.
157+
158+
Official support for SQLite and MySQL is [planned for a future
159+
release](https://github.com/jeancochrane/pytest-flask-sqlalchemy/issues/3).
160+
In the meantime, if you're using one of those backends and you run in to
161+
problems, we would greatly appreciate your help! [Open an
162+
issue](https://github.com/jeancochrane/pytest-flask-sqlalchemy/issues/new) if
163+
something isn't working as you expect.
164+
150165
## <a name="configuration"></a>Configuration
151166

152167
### <a name="conftest-setup"></a>Conftest setup
@@ -448,6 +463,10 @@ whose blog post ["Delightful testing with pytest and
448463
Flask-SQLAlchemy"](http://alexmic.net/flask-sqlalchemy-pytest/) helped
449464
establish the basic approach on which this plugin builds.
450465

466+
Many thanks to [Igor Ghisi](https://github.com/igortg/), who donated the PyPi
467+
package name. Igor had been working on a similar plugin and proposed combining
468+
efforts. Thanks to Igor, the plugin name is much stronger.
469+
451470
## <a name="copyright"></a>Copyright
452471

453472
Copyright (c) 2018 Jean Cochrane and DataMade. Released under the MIT License.
File renamed without changes.

transactions/fixtures.py renamed to pytest_flask_sqlalchemy/fixtures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def _db():
1212
Session object that can access the test database. If the user hasn't defined
1313
that fixture, raise an error.
1414
'''
15-
msg = ("_db fixture not defined. The pytest-flask-sqlalchemy-transactions plugin " +
16-
"requires you to define a _db fixture that returns a SQLAlchemy session " +
15+
msg = ("_db fixture not defined. The pytest-flask-sqlalchemy plugin " +
16+
"requires you to define a _db fixture that returns a SQLAlchemy Session " +
1717
"with access to your test database. For more information, see the plugin " +
1818
"documentation: " +
19-
"https://github.com/jeancochrane/pytest-flask-sqlalchemy-transactions#conftest-setup")
19+
"https://github.com/jeancochrane/pytest-flask-sqlalchemy#conftest-setup")
2020

2121
raise NotImplementedError(msg)
2222

File renamed without changes.

setup.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
'''
2-
pytest-flask-sqlalchemy-transactions
3-
====================================
4-
5-
Run tests in transactions using pytest, Flask, and SQLAlchemy.
6-
'''
71
from setuptools import setup
82

93

@@ -12,16 +6,16 @@ def readme():
126
return f.read()
137

148
setup(
15-
name='pytest-flask-sqlalchemy-transactions',
9+
name='pytest-flask-sqlalchemy',
1610
author='Jean Cochrane',
1711
author_email='[email protected]',
18-
url='https://github.com/jeancochrane/pytest-flask-sqlalchemy-transactions',
19-
description='Run tests in transactions using pytest, Flask, and SQLalchemy.',
12+
url='https://github.com/jeancochrane/pytest-flask-sqlalchemy',
13+
description='A pytest plugin for preserving test isolation in Flask-SQlAlchemy using database transactions.',
2014
long_description=readme(),
2115
long_description_content_type='text/markdown',
2216
license='MIT',
23-
version='1.0.1',
24-
packages=['transactions'],
17+
version='1.0.0',
18+
packages=['pytest_flask_sqlalchemy'],
2519
install_requires=['pytest>=3.2.1',
2620
'pytest-mock>=1.6.2',
2721
'SQLAlchemy>=1.2.2',
@@ -42,7 +36,7 @@ def readme():
4236
# Make the package available to pytest
4337
entry_points={
4438
'pytest11': [
45-
'pytest-flask-sqlalchemy-transactions = transactions.plugin',
39+
'pytest-flask-sqlalchemy = pytest_flask_sqlalchemy.plugin',
4640
]
4741
},
4842
)

tests/_conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
else:
2020
DB_OPTS = sa.engine.url.make_url(DB_CONN).translate_connect_args()
2121

22-
pytest_plugins = ['pytest-flask-sqlalchemy-transactions']
22+
pytest_plugins = ['pytest-flask-sqlalchemy']
2323

2424

2525
@pytest.fixture(scope='session')

tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
import pytest
24

35
# This import prevents SQLAlchemy from throwing an AttributeError
@@ -14,7 +16,7 @@ def conftest():
1416
Load configuration file for the tests to a string, in order to run it in
1517
its own temporary directory.
1618
'''
17-
with open('tests/_conftest.py', 'r') as conf:
19+
with open(os.path.join('tests', '_conftest.py'), 'r') as conf:
1820
conftest = conf.read()
1921

2022
return conftest

tests/test_configs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def test_mocked_sessionmakers(db_testdir):
5353
db_testdir.makepyfile("""
5454
def test_mocked_sessionmakers(db_session):
5555
from collections import namedtuple, Counter
56-
assert str(namedtuple).startswith("<transactions.fixtures._session.<locals>.FakeSessionMaker")
57-
assert str(Counter).startswith("<transactions.fixtures._session.<locals>.FakeSessionMaker")
56+
assert str(namedtuple).startswith("<pytest_flask_sqlalchemy.fixtures._session.<locals>.FakeSessionMaker")
57+
assert str(Counter).startswith("<pytest_flask_sqlalchemy.fixtures._session.<locals>.FakeSessionMaker")
5858
""")
5959

6060
result = db_testdir.runpytest()
@@ -88,7 +88,7 @@ def test_missing_db_fixture(testdir):
8888
else:
8989
DB_OPTS = sa.engine.url.make_url(DB_CONN).translate_connect_args()
9090
91-
pytest_plugins = ['pytest-flask-sqlalchemy-transactions']
91+
pytest_plugins = ['pytest-flask-sqlalchemy']
9292
9393
9494
@pytest.fixture(scope='session')

0 commit comments

Comments
 (0)