Skip to content

Commit e489630

Browse files
committed
Tests: Replace Flask with minimal test scaffolding
1 parent 334c512 commit e489630

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

tests.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,28 @@ def run(self, remaining_args, foo):
147147
print(remaining_args)
148148

149149

150-
class TestCommands(unittest.TestCase):
151-
152-
TESTING = True
153-
154-
def setup(self):
150+
class EmptyContext(object):
151+
def __enter__(self):
152+
pass
153+
def __exit__(self, a,b,c):
154+
pass
155155

156-
self.app = Flask(__name__)
157-
self.app.config.from_object(self)
156+
class TestApp(object):
157+
def __init__(self, verbose=False):
158+
self.verbose = verbose
159+
def test_request_context(self):
160+
return EmptyContext()
161+
def __call__(self,**kw):
162+
if self.verbose:
163+
print("APP "+" ".join("%s=%s" % (k,v) for k,v in kw.items()))
164+
return self
158165

159166

160167
class TestManager:
161168

162-
TESTING = True
163-
164169
def setup(self):
165170

166-
self.app = Flask(__name__)
167-
self.app.config.from_object(self)
171+
self.app = TestApp()
168172

169173
def test_with_default_commands(self):
170174

@@ -636,12 +640,9 @@ def correct_n(msg):
636640

637641
class TestSubManager:
638642

639-
TESTING = True
640-
641643
def setup(self):
642644

643-
self.app = Flask(__name__)
644-
self.app.config.from_object(self)
645+
self.app = TestApp()
645646

646647
def test_add_submanager(self):
647648

0 commit comments

Comments
 (0)