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

Build fails, probably because behave can't find steps directory #64

Open
bittner opened this issue Jun 15, 2018 · 8 comments
Open

Build fails, probably because behave can't find steps directory #64

bittner opened this issue Jun 15, 2018 · 8 comments

Comments

@bittner
Copy link
Member

bittner commented Jun 15, 2018

The current build for PR #63 fails. When I run behave or python manage.py behave locally I get:

$ behave
ConfigError: No steps directory in '/home/peter/Development/repos/behave-django'
$ python manage.py behave
Creating test database for alias 'default'...
ConfigError: No steps directory in '/home/peter/Development/repos/behave-django'
Destroying test database for alias 'default'...

I've done some research and found some probably unrelated issue in the behave project. Not sure.

The problem seems to be related to how behave discovers the steps/ folder when paths are specified in the behave configuration.

@bittner
Copy link
Member Author

bittner commented Jul 24, 2018

Note to self: Try behave --verbose for diagnosis (as proposed by Jens)

@bittner
Copy link
Member Author

bittner commented Oct 21, 2018

Side note: In the builds a CLI test is failing, but really the multiple-feature-directories.feature should fail for the problem the failing build is exposing. 😟

@bittner
Copy link
Member Author

bittner commented Oct 21, 2018

Current result of problem analysis, after some refactoring:

A) When a single path is specified in the behave configuration everything works as expected, e.g.

[behave]
paths = tests/acceptance

... even with some special directory layout, e.g.

tests/acceptance/
├── environment.py
├── features
│   └── foo-bar.feature
└── steps
    └── foo_bar.py

B) When several paths are specified neither of those paths is looked at, e.g.

[behave]
paths =
    tests/acceptance
    tests/test_app/features

... same with just the parent path, e.g.

[behave]
paths =
    tests/acceptance
    tests/test_app

C) When a single path is specified in the ini-style file list notation the execution fails alike, e.g.

[behave]
paths =
    tests/test_app/features

Hence, it looks like the ini-style file list notation is causing problems. Or, in other words, behave only accepts paths to be a (single line of) string.

@bittner
Copy link
Member Author

bittner commented Oct 22, 2018

Aha! Gotcha!

The behave documentation shows a configuration example, which starts the value list right in the same line as the equal sign. This syntax, interestingly enough, works. However, if only one of the locations contains a steps/ directory that location has to come first!

Example:

[behave]
paths = tests/acceptance
        tests/test_app

In this setup the tests/acceptance folder has to contain both a features/ and a steps/ (or a combined features/steps/) folder. Here it's sufficient that tests/test_app only contains a features/ directory (no steps!).

The other way round:

[behave]
paths = tests/test_app
        tests/acceptance

... behave will abort execution:

ConfigError: No steps directory in '/home/.../repos/behave-django/tests/test_app'

I'm not sure whether both behaviors are intended:

  1. sequence<text> is a text with newlines (not a list), list syntax is not allowed or meant to be used -- (see documentation)
  2. *.feature files can be scattered around in several locations, but (at least) the first location does have to also provide a steps/ directory with the implementations. (Yet still, the steps implementations will be shared. The first location may even just point to a steps/ directory.) -- (the documentation doesn't mention this explicitly)

@jenisys, any comments or clarifications?

@jenisys
Copy link
Member

jenisys commented Oct 22, 2018

@bittner
Currently, only one location for the steps is supported per test run.
You can work around that by using build-scripts (makefile, invoke, etc.) to run behave with a list of folders (as sequence).

NOTE: The configparser module implements/requires the behaviour that the first item needs to be in the first line. Normal case for "append-mode" where many values are allowed.

@bittner
Copy link
Member Author

bittner commented Oct 23, 2018

The configparser module implements/requires the behaviour that the first item needs to be in the first line. Normal case for "append-mode" where many values are allowed.

When I try ConfigParser with a "list-style" syntax it's returning me the string value starting with a newline. Hence, the behavior in Behave may be implementation-specific and could be changed. Any thoughts?

>>> cp = configparser.ConfigParser()
>>> list_config = """[behave]
... my_list =
...     foo
...     bar
...     baz
... """
>>> cp.read_string(list_config)
>>> cp['behave'].get('my_list')
'\nfoo\nbar\nbaz'

@jenisys
Copy link
Member

jenisys commented Oct 23, 2018

Provide a pull-request for behave/configuration.py:399 that "corrects" this behaviour (but a trailing .split() or .splitlines() is still needed).

NOTE:

  • Weird that the slightly different API usage results in different behaviour ?!?
  • Note that your example will raise an exception if the [behave] section does not exist.
  • I encountered this behaviour in many other projects w/ configparser (and argparse).

@bittner
Copy link
Member Author

bittner commented Dec 2, 2018

@jenisys The fix for this is really easy. Writing the tests (mocking the ConfigParser) is a pain, though. I've tried this with a colleague. Not nice. I may place a PR anytime soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants