Skip to content

Commit

Permalink
Rename the plugin to 'pytest-flask-sqlalchemy'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeancochrane committed Aug 2, 2018
1 parent 4f3111e commit 16d0595
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*.egg-info
__pycache__
.pytest_cache
.cache
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -448,6 +448,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.

## <a name="copyright"></a>Copyright

Copyright (c) 2018 Jean Cochrane and DataMade. Released under the MIT License.
Expand Down
File renamed without changes.
Expand Up @@ -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)

Expand Down
File renamed without changes.
18 changes: 6 additions & 12 deletions setup.py
@@ -1,9 +1,3 @@
'''
pytest-flask-sqlalchemy-transactions
====================================
Run tests in transactions using pytest, Flask, and SQLAlchemy.
'''
from setuptools import setup


Expand All @@ -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',
Expand All @@ -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',
]
},
)
2 changes: 1 addition & 1 deletion tests/_conftest.py
Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
@@ -1,3 +1,5 @@
import os

import pytest

# This import prevents SQLAlchemy from throwing an AttributeError
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test_configs.py
Expand Up @@ -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("<transactions.fixtures._session.<locals>.FakeSessionMaker")
assert str(Counter).startswith("<transactions.fixtures._session.<locals>.FakeSessionMaker")
assert str(namedtuple).startswith("<pytest_flask_sqlalchemy.fixtures._session.<locals>.FakeSessionMaker")
assert str(Counter).startswith("<pytest_flask_sqlalchemy.fixtures._session.<locals>.FakeSessionMaker")
""")

result = db_testdir.runpytest()
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 16d0595

Please sign in to comment.