Skip to content

Commit

Permalink
Use other mysql login in tools unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryp Toon committed Feb 6, 2024
1 parent 1545324 commit 556e97f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unittests-mysql.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bitcoinlib Tests Ubuntu MySQL
name: Bitcoinlib Tests Ubuntu - MySQL
on: [push]

jobs:
Expand Down
3 changes: 2 additions & 1 deletion bitcoinlib/db_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def __init__(self, db_uri=None):

def drop_db(self):
self.session.commit()
self.session.close_all()
self.session.close()
session.close_all_sessions()
Base.metadata.drop_all(self.engine)


Expand Down
5 changes: 1 addition & 4 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ def database_init(dbname=DATABASE_NAME):
con.close()
return 'postgresql://postgres:postgres@localhost:5432/' + dbname
elif os.getenv('UNITTEST_DATABASE') == 'mysql':
try:
con = mysql.connector.connect(user='root', host='localhost')
except mysql.connector.errors.ProgrammingError:
con = mysql.connector.connect(user='user', host='localhost', password='password')
con = mysql.connector.connect(user='user', host='localhost', password='password')
cur = con.cursor()
cur.execute("DROP DATABASE IF EXISTS {}".format(dbname))
cur.execute("CREATE DATABASE {}".format(dbname))
Expand Down

0 comments on commit 556e97f

Please sign in to comment.