Add common FileConfigTestCase
class, in new testing
module
hoping i do not regret this decision.. since the tests do not live in a "real" package i think the only way to share code is to add some things to the main package
This commit is contained in:
parent
427afc27fc
commit
a0186b346e
4 changed files with 92 additions and 28 deletions
|
@ -2,8 +2,6 @@
|
|||
|
||||
import configparser
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from unittest import TestCase
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
|
@ -13,21 +11,10 @@ from wuttjamaican import conf
|
|||
from wuttjamaican.exc import ConfigurationError
|
||||
from wuttjamaican.db import Session
|
||||
from wuttjamaican.app import AppHandler
|
||||
from wuttjamaican.testing import FileConfigTestCase
|
||||
|
||||
|
||||
class TestWuttaConfig(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tempdir)
|
||||
|
||||
def write_file(self, filename, content):
|
||||
path = os.path.join(self.tempdir, filename)
|
||||
with open(path, 'wt') as f:
|
||||
f.write(content)
|
||||
return path
|
||||
class TestWuttaConfig(FileConfigTestCase):
|
||||
|
||||
def test_contstructor_basic(self):
|
||||
config = conf.WuttaConfig()
|
||||
|
@ -430,24 +417,12 @@ class TestGenericDefaultFiles(TestCase):
|
|||
self.assertEqual(len(files), 0)
|
||||
|
||||
|
||||
class TestMakeConfig(TestCase):
|
||||
class TestMakeConfig(FileConfigTestCase):
|
||||
|
||||
# nb. we use appname='wuttatest' in this suite to avoid any
|
||||
# "valid" default config files, env vars etc. which may be present
|
||||
# on the dev machine
|
||||
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tempdir)
|
||||
|
||||
def write_file(self, filename, content):
|
||||
path = os.path.join(self.tempdir, filename)
|
||||
with open(path, 'wt') as f:
|
||||
f.write(content)
|
||||
return path
|
||||
|
||||
def test_generic_default_files(self):
|
||||
generic = self.write_file('generic.conf', '')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue