Skip to content

fix: Configuration argument verbose unused#1264

Open
satelliteprogrammer wants to merge 1 commit intobehave:mainfrom
satelliteprogrammer:main
Open

fix: Configuration argument verbose unused#1264
satelliteprogrammer wants to merge 1 commit intobehave:mainfrom
satelliteprogrammer:main

Conversation

@satelliteprogrammer
Copy link
Copy Markdown

Configuration is not applying the verbose it receives as argument.

The issue is that the init method receives verbose as a separate
argument from all others and is not passing it to make_default. The
defaults are then passed to the ArgumentParser, which would be missing
the verbose initially passed to Configuration, and where verbose has
action="proxy.php?url=https%3A%2F%2Fgithub.com%2Fstore_true", making it default to False.

This patch also stores verbose in the defaults used by the arg parser.

Configuration is not applying the verbose it receives as argument.

The issue is that the `init` method receives `verbose` as a separate
argument from all others and is not passing it to `make_default`. The
defaults are then passed to the `ArgumentParser`, which would be missing
the verbose initially passed to `Configuration`, and where verbose has
action="proxy.php?url=https%3A%2F%2Fgithub.com%2Fstore_true", making it default to False.

This patch also stores `verbose` in the defaults used by the arg parser.
@satelliteprogrammer
Copy link
Copy Markdown
Author

Hi. I checked the tests, but the test_configuration.py seemed just focused on either configuration from the command line or through a config file.
We're calling behave through another test framework, which makes it easier to configure by initialising Configuration directly.

@jenisys
Copy link
Copy Markdown
Member

jenisys commented Aug 23, 2025

I a not quite sure what your problem exactly is (except that I think you are mistaken).
Using the --verbose option on the command-line works as expected.
The default for verbose mode is false.

  • Can you explain what the exact problem is that you are trying to solve !
  • Explain what is not as you expected and what you expected instead !

@satelliteprogrammer
Copy link
Copy Markdown
Author

Hi @jenisys,

The issue is when instantiating a Configuration object and passing it verbose as a keyword argument.

The following would not enable verbose mode.

config = Configuration(verbose=True)
assert run_behave(config) == os.EX_OK

despite verbose being in the Configuration definition.

class Configuration(object):
    def __init__(self, command_args=None, load_config=True, verbose=None, **kwargs):

If verbose is explicitly offered as an argument my expectation is that setting it to True would enable verbose logging.

@jenisys
Copy link
Copy Markdown
Member

jenisys commented Aug 24, 2025

I will think about it.
But note that the following parameter usage performs what you desire:

config = Configuration([“—verbose“])
assert config.verbose is True
assert run_behave(config) == os.EX_OK

@satelliteprogrammer
Copy link
Copy Markdown
Author

And that's probably what we will use for now.
However, given that we're calling Configuration directly and the library offers a possibility to pass arguments directly, it's much nice to organize all options in a dictionary and then expand it when calling Configuration.

options = {
    "junit": True,
    "load_config": False,
    # ...
    "verbose": True,
}

config = Configuration([], tags=tags, paths=[tests_path()], stage="", **options)

@jenisys jenisys force-pushed the main branch 6 times, most recently from 370ce68 to cba3c4f Compare August 31, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants