Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask 1.1 breakage #126

Closed
guruofgentoo opened this issue Oct 31, 2019 · 1 comment
Closed

Flask 1.1 breakage #126

guruofgentoo opened this issue Oct 31, 2019 · 1 comment
Labels

Comments

@guruofgentoo
Copy link
Member

Tests are not passing with Flask 1.1, specifically from TestCLI2. Probably related to #90, but I wanted to document this limit. #125 adjusts the requirements to limit flask version.

@nZac
Copy link
Contributor

nZac commented Nov 21, 2019

I dug into this a fair bit more because I wanted a 1.1 feature. These are the tests that fail:

class TestCLI2(CLIBase):
@classmethod
def setup_class(cls):
CLIBase.setup_class()
# Use this, instead of setting app_cls on the testing class, in order to test that the
# machinery in place for using the current app is working.
CLI2App.testing_prep()
def test_invoke(self):
result = self.invoke('hello1')
assert 'hello1' in result.output
def test_no_commands_help_message(self):
result = self.invoke()
assert 'Usage: ' in result.output
assert '--quiet Set default logging level to logging.WARNING' in result.output
assert '--profile TEXT Name of the configuration profile to use.' in result.output
assert '--help-all Show all commands with subcommands.' in result.output
assert 'develop Developer info and utils.' in result.output
assert 'hello1' in result.output
def test_quiet(self):
# the asserts for these tests are in keg_apps.cli2.cli
result = self.invoke('--quiet', 'is-quiet')
assert 'printed foo' in result.output
assert 'logged foo' not in result.output
result = self.invoke('is-not-quiet')
assert 'printed foo' in result.output
assert 'logged foo' in result.output
def test_help_all(self):
expected_lines = [
'Usage', '', 'Options', '--profile', '--quiet', '--help-all', '--help',
'Commands', 'develop', 'Commands', 'config', 'db', 'Commands', 'clear',
'init', 'keyring', 'Commands', 'delete', 'list-keys', 'status', 'routes',
'run', 'shell', 'templates', 'hello1', 'is-not-quiet', 'is-quiet', 'reverse',
''
]
result = self.invoke('--help-all')
output_lines = result.output.split('\n')
assert len(expected_lines) == len(output_lines), result.output
for command, line in zip(expected_lines, output_lines):
assert line.lstrip().startswith(command), f'"{line}" does not start with "{command}"'
def test_handle_input(self):
result = self.invoke('reverse', input='abcde')
assert 'Input: abcde' in result.output
assert 'edcba' in result.output

It doesn't seem to be related directly to #90, as applying that patch doesn't fix the issue but there is something wonky happening with the import_name with

class CLI2App(Keg):
import_name = 'keg_apps.cli2'
def on_init_complete(self):
# Want to test when the CLI command is registered after the app is initialized
import keg_apps.cli2.cli # noqa

Everything breaks because of this tests:

class TestInit(object):
def test_init_called_twice_error(self):
with pytest.raises(KegAppError, match=r'init\(\) already called on this instance'):
app = Keg(__name__)
app.init(use_test_profile=True)
app.init(use_test_profile=True)
but I can't seem to figure out why. This doesn't seem to do anything special but removing it fixes the other breaking tests.

I ran a git bisect and discovered that this is the first failing commit: pallets/flask@ec1ccd7. I think because they changed the where the CLI gets setup and how it changes in the Flask.__init__ we are having some weird interaction when an error occurs from the first test. I wasn't able to figure out where that would be.

A Keg app does not normally fail, this seems to be only a testing issue.

I wonder if it would be good to take a look at the CLI setup and restructure that from a first-principles view.

@nZac nZac added the bug label Nov 21, 2019
nZac pushed a commit that referenced this issue Nov 29, 2019
nZac pushed a commit that referenced this issue Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants