To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit ca6f44f0 authored by vermeul's avatar vermeul
Browse files

adjusted mysql db connection

parent d6327780
......@@ -26,6 +26,7 @@ $ pytest tests/ -k "test_current_work"
```python
import pytest
import os
import mysql.connector
@pytest.fixture(scope="session")
def mysql_conn():
......@@ -34,15 +35,16 @@ def mysql_conn():
db_user = os.getenv("DB_USER")
db_password = os.getenv("DB_PASSWORD")
engine = create_engine(
f"mysql+pymysql://{db_user}:{db_password}@{db_host}:3306/{db_name}"
mydb = mysql.connector.connect(
host=db_host,
user=db_user,
password=db_password,
database=db_name,
)
connection = engine.connect()
yield mydb
yield connection
connection.close()
mydb.close()
```
And then use fixture in your testing module(s), using the `mysql_conn` fixture as the first parameter:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment