Use test database for tests

This commit is contained in:
Mathieu Comandon 2014-08-18 12:02:35 +02:00
parent 5db34df75e
commit b4f7df7d4f
2 changed files with 16 additions and 2 deletions

View file

@ -1,10 +1,25 @@
import os
from gi.repository import Gio
from lutris.game import Game
from lutris import pga
from lutris.gui import config_dialogs
from unittest import TestCase
from lutris import runners
TEST_PGA_PATH = os.path.join(os.path.dirname(__file__), 'pga.db')
class DatabaseTester(TestCase):
def setUp(self):
pga.PGA_DB = TEST_PGA_PATH
if os.path.exists(TEST_PGA_PATH):
os.remove(TEST_PGA_PATH)
pga.syncdb()
def tearDown(self):
if os.path.exists(TEST_PGA_PATH):
os.remove(TEST_PGA_PATH)
class TestGameDialogCommon(TestCase):
def test_get_runner_liststore(self):
@ -15,7 +30,7 @@ class TestGameDialogCommon(TestCase):
self.assertEqual(list_store[1][1], runners.__all__[0])
class TestGameDialog(TestCase):
class TestGameDialog(DatabaseTester):
def test_dialog(self):
dlg = config_dialogs.AddGameDialog(None)
self.assertEqual(dlg.notebook.get_current_page(), 0)

View file

@ -1,4 +1,3 @@
#!/usr/bin/python
import unittest
import os
from sqlite3 import IntegrityError, OperationalError