Browse Source

Parameterize test_get_debug_flag

pull/2303/head
MikeTheReader 8 years ago
parent
commit
cd412b20dc
  1. 34
      tests/test_helpers.py

34
tests/test_helpers.py

@ -945,26 +945,20 @@ class TestSafeJoin(object):
class TestHelpers(object): class TestHelpers(object):
def test_get_debug_flag(self, monkeypatch): @pytest.mark.parametrize("debug, expected_flag, expected_default_flag", [
monkeypatch.setenv('FLASK_DEBUG', '') ('', None, True),
assert get_debug_flag() == None ('0', False, False),
assert get_debug_flag(default=True) == True ('False', False, False),
('No', False, False),
monkeypatch.setenv('FLASK_DEBUG', '0') ('True', True, True)
assert get_debug_flag() == False ])
assert get_debug_flag(default=True) == False def test_get_debug_flag(self, monkeypatch, debug, expected_flag, expected_default_flag):
monkeypatch.setenv('FLASK_DEBUG', debug)
monkeypatch.setenv('FLASK_DEBUG', 'False') if expected_flag is None:
assert get_debug_flag() == False assert get_debug_flag() is None
assert get_debug_flag(default=True) == False else:
assert get_debug_flag() == expected_flag
monkeypatch.setenv('FLASK_DEBUG', 'No') assert get_debug_flag(default=True) == expected_default_flag
assert get_debug_flag() == False
assert get_debug_flag(default=True) == False
monkeypatch.setenv('FLASK_DEBUG', 'True')
assert get_debug_flag() == True
assert get_debug_flag(default=True) == True
def test_make_response(self): def test_make_response(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)

Loading…
Cancel
Save