@@ -27,7 +27,7 @@ transactions using [Flask-SQLAlchemy](http://flask-sqlalchemy.pocoo.org/latest/)
2727 - [ Acknowledgements] ( #acknowledgements )
2828 - [ Copyright] ( #copyright )
2929
30- ## Motivation
30+ ## < a name = " motivation " ></ a > Motivation
3131
3232Inspired by [ Django's built-in support for transactional
3333tests] ( https://jeancochrane.com/blog/django-test-transactions ) , this plugin
@@ -37,7 +37,7 @@ apps. The goal is to make testing stateful Flask-SQLAlchemy applications easier
3737providing fixtures that permit the developer to ** make arbitrary database updates
3838with the confidence that any changes made during a test will roll back** once the test exits.
3939
40- ## Quick examples
40+ ## < a name = " quick-examples " ></ a > Quick examples
4141
4242Use the [ ` db_session ` fixture] ( #db_session ) to make ** database updates that won't persist beyond
4343the body of the test** :
@@ -116,11 +116,11 @@ def test_transaction_doesnt_persist(db_session):
116116 assert row.name != ' testing'
117117```
118118
119- # Usage
119+ # < a name = " usage " ></ a > Usage
120120
121- ## Installation
121+ ## < a name = " installation " ></ a > Installation
122122
123- ### From PyPi
123+ ### < a name = " from-pypi " ></ a > From PyPi
124124
125125Install using pip:
126126
@@ -132,7 +132,7 @@ Once installed, pytest will detect the plugin automatically during test collecti
132132For basic background on using third-party plugins with pytest, see the [ pytest
133133documentation] ( https://docs.pytest.org/en/latest/plugins.html?highlight=plugins ) .
134134
135- ### Development version
135+ ### < a name = " development-version " ></ a > Development version
136136
137137Clone the repo from GitHub and switch into the new directory:
138138
@@ -153,9 +153,9 @@ Or install the plugin dependencies manually:
153153pip install -r requirements/main.txt
154154```
155155
156- ## Configuration
156+ ## < a name = " configuration " ></ a > Configuration
157157
158- ### Conftest setup
158+ ### < a name = " conftest-setup " ></ a > Conftest setup
159159
160160This plugin assumes that a fixture called ` _db ` has been
161161defined in the root conftest file for your tests. The ` _db ` fixture should
@@ -226,7 +226,7 @@ def _db(database):
226226 return database
227227```
228228
229- ### Test configuration
229+ ### < a name = " test-configuration " ></ a > Test configuration
230230
231231This plugin allows you to configure a few different properties in a
232232` setup.cfg ` test configuration file in order to handle the specific database connection needs
@@ -246,7 +246,7 @@ The configured patches are only applied in tests where a transactional fixture
246246(either [ ` db_session ` ] ( #db_session ) or [ ` db_engine ` ] ( #db_engine ) ) is included
247247in the test function arguments.
248248
249- #### ` mocked-engines `
249+ #### < a name = " mocked-engines " ></ a > ` mocked-engines `
250250
251251The ` mocked-engines ` property directs the plugin to [ patch] ( https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch )
252252objects in your codebase, typically SQLAlchemy [ Engine] ( http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Engine )
@@ -281,7 +281,7 @@ To patch multiple objects at once, separate the paths with a whitespace:
281281mocked-engines =database.engine database.second_engine
282282```
283283
284- #### ` mocked-sessions `
284+ #### < a name = " mocked-sessions " ></ a > ` mocked-sessions `
285285
286286The ` mocked-sessions ` property directs the plugin to [ patch] ( https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch )
287287objects in your codebase, typically SQLAlchemy [ Session] ( http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Engine )
@@ -316,7 +316,7 @@ To patch multiple objects at once, separate the paths with a whitespace:
316316mocked-sessions =database.db.session database.second_db.session
317317```
318318
319- #### ` mocked-sessionmakers `
319+ #### < a name = " mocked-sessionmakers " ></ a > ` mocked-sessionmakers `
320320
321321The ` mocked-sessionmakers ` property directs the plugin to [ patch] ( https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch )
322322objects in your codebase, typically instances of [ SQLAlchemy's ` sessionmaker `
@@ -349,14 +349,14 @@ To patch multiple objects at once, separate the paths with a whitespace.
349349mocked-sessionmakers =database.WorkerSessionmaker database.SecondWorkerSessionmaker
350350```
351351
352- ## Fixtures
352+ ## < a name = " fixtures " ></ a > Fixtures
353353
354354This plugin provides two fixtures for performing database updates inside nested
355355transactions that get rolled back at the end of a test: [ ` db_session ` ] ( #db_session ) and
356356[ ` db_engine ` ] ( #db_engine ) . The fixtures provide similar functionality, but
357357with different APIs.
358358
359- ### ` db_session `
359+ ### < a name = " db_session " ></ a > ` db_session `
360360
361361The ` db_session ` fixture allows you to perform direct updates that will be
362362rolled back when the test exits. It exposes the same API as [ SQLAlchemy's
@@ -382,7 +382,7 @@ def test_transaction_doesnt_persist(db_session):
382382 assert row.name != ' testing'
383383```
384384
385- ### ` db_engine `
385+ ### < a name = " db_engine " ></ a > ` db_engine `
386386
387387Like [ ` db_session ` ] ( #db_session ) , the ` db_engine ` fixture allows you to perform direct updates
388388against the test database that will be rolled back when the test exits. It is
@@ -417,9 +417,9 @@ def test_transaction_doesnt_persist(db_engine):
417417 assert row_name != ' testing'
418418```
419419
420- # Development
420+ # < a name = " development " ></ a > Development
421421
422- ## Running the tests
422+ ## < a name = " running-the-tests " ></ a > Running the tests
423423
424424Start by ensuring that all test requirements are installed:
425425
@@ -447,7 +447,7 @@ Finally, run the tests using pytest:
447447pytest
448448```
449449
450- ## Acknowledgements
450+ ## < a name = " acknowledgements " ></ a > Acknowledgements
451451
452452This plugin was initially developed for testing
453453[ Dedupe.io] ( https://dedupe.io ) , a web app for record linkage and entity
@@ -459,7 +459,7 @@ whose blog post ["Delightful testing with pytest and
459459Flask-SQLAlchemy"] ( http://alexmic.net/flask-sqlalchemy-pytest/ ) helped
460460establish the basic approach on which this plugin builds.
461461
462- ## Copyright
462+ ## < a name = " copyright " ></ a > Copyright
463463
464464Copyright (c) 2018 Jean Cochrane and DataMade. Released under the MIT License.
465465
0 commit comments