You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-5Lines changed: 29 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,36 @@
2
2
SQLAlchemy related fixtures to handle connections and transactions with SQLAlchemy in tests.
3
3
4
4
## Fixtures
5
-
This plugin provides the following fixtures:
5
+
This plugin provides the following fixtures which gives access to the SQLAlchmey objects of the same name.
6
6
7
-
1.**engine** The engine used to connect to the database. Scope is "module".
8
-
1.**connection** An open connection to the database. Scope is "module".
9
-
1.**transaction** A started transaction on the connection. Transaction will be rolled back. No Scope.
10
-
1.**dbsession** A sqlalchemy session *not* bound to any model. No scope.
7
+
***engine** The engine used to connect to the database. Scope is "module".
8
+
***connection** An open connection to the database. Scope is "module".
9
+
10
+
See [Working with Engines and Conncetions](http://docs.sqlalchemy.org/en/latest/core/connections.html#module-sqlalchemy.engine) on how to use this fixtues.
11
+
12
+
***transaction** A started transaction on the connection. Transaction will be rolled back. No Scope.
13
+
14
+
See [Using Transactions](http://docs.sqlalchemy.org/en/latest/core/connections.html#using-transactions) on how to use this fixtures
15
+
16
+
***dbsession** A sqlalchemy session *not* bound to any model. No scope.
17
+
18
+
See [Session Basisc](http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#session-basics) to learn about how to use sessions.
19
+
20
+
## Usage
21
+
The fixtures can be used in your tests like any other [Pytest Fixtures](https://docs.pytest.org/en/3.6.1/fixture.html).
22
+
23
+
**Example**:
24
+
25
+
```python
26
+
import pytest
27
+
from pytest_sqlalchemy import connection
28
+
29
+
deftest_connection(connection):
30
+
# Do fancy stuff with the connection.
31
+
# Note you will not need to close the connection. This is done
32
+
# automatically when the scope (module) of the fixtures ends.
33
+
assert connection
34
+
````
11
35
12
36
## Invoke
13
37
You need to provide the connection URLfor the engine when invoking the pytest command::
0 commit comments