سؤال

I am trying to test the configuration of my app, I need to set a flag if app.config['TEST'] is True

Here's the configuration part of my app

app.config['TEST'] = False
if app.config['TEST']:
    app.config['FOO'] = 'bar'
else:
    app.config['FOO'] = 'baz'

Here's the testcase that is failing:

class TestConfigCase(TestCase):
    def setUp(self):
        app.app.config['TESTING'] = True
        self.app = app.app.test_client()

    def testConfig(self):
        assert 'bar' in self.app.config['FOO']
هل كانت مفيدة؟

المحلول

In the beginning you have TEST and then you are writing TESTING.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top