Comments (6)
I assume that you are using the pretty
formatter ?!?
In this case, the —no-color
option causes a different behavior in the pretty
formatter. In colored mode, it writes the steps twice:
- Once before it is executed (in gray)
- And another time after the step has finished and the result is known
- It overwrites how much lines this step needs
If you do not capture the output, behave
is not aware of any printed output.
Therefore, such output lines are overwritten.
You seem to need a feature, like:
show-always-captured-output
(after the step is executed or after scenario is executed)- You should be able to provide the basic functionality for this by using an
after_scenario()
hook that uses:
def after_scenario(ctx, scenario):
# PRECONDITION: Captured output is stored only if junit reporter is enabled (for passing scenarios).
report = scenario.captured.make_report()
if report:
print(report)
- You could do the same with an
after_step()
hook, that output thectx.scenario.captured.make_report()
. To simplify things, you should probably reset the captured output after each step.
from behave.
Sorry, I disagree.
That is as if you blame your car manufacturer that you are in a traffic jam.
If you use -no-capture
, etc. the output/log-output is outside of behave
.
Therefore, behave
can not do anything about it. That is a deficit of the pretty
formatter and maybe unexpected for you and others. But you are free to:
- choose another formatter
- use the
pretty
formatter without color - capture the output/log-output and
- perform something like
show-always-captured-output
with captured-output/log-output (where currently only rudimentary support exists) - use logging to a file without capturing it (to inspect it later-on)
OTHERWISE:
If you have a better, robust solution how the pretty
formatter should behave in colored mode, provide a pull-request.
from behave.
MAYBE RELATED FIX:
- #1120 — INTEGRATED INTO:
behave v1.2.7.dev4
Therefore, try the tip of the repository or behave v1.2.7.dev4
or newer (installed from the Git repository)
NOTE:
By shortly looking over the implementation, —no-color
option should not have any effect on logging output.
from behave.
This bug isn’t specific to logging. It seems that if a step writes to stdout (and it isn’t captured), then the last line of output is lost. A logger configured as above is one way to hit this. A plain old print statement is another.
My assumption is it gets overwritten when behave tries to change the step text to green.
from behave.
@jenisys This is clearly a bug in behave caused by two of its features (--color
and --no-capture
) interacting poorly. It's not a feature request, and I'm not "mistaken".
To fix this bug, the "pretty print" logic or whatever needs to be fixed to detect this situation and respond appropriately.
from behave.
No, it's as if turning on the windshield wiper caused the radio to stop working, and my car manufacturer refused to admit there was a problem.
The bug comes from here, where it uses a special ANSI code to "rewind" the terminal to the previous line.
behave/behave/formatter/pretty.py
Line 152 in 1c6197b
I don't use ANSI escape sequences, but it seems you should use the DSR
escape sequence to get the current offset before writing the step text (orig_offset
). Then after the step has executed, save the current offset again (new_offset
), use the CUP
escape sequence to restore orig_offset
, overwrite the step text in green/red, and then restore new_offset
. Of course, that will not work properly if stdin is being used for another purpose.
Barring that, you should (1) change the default behavior to disable colors if any output capture is disabled, and (2) amend the documentation for --color
to mention this flaw.
from behave.
Related Issues (20)
- Add type information for `mypy` and type hints? HOT 4
- Question: Is there a way to properly set result for behave run? HOT 2
- TagExpression auto-detection is not working properly HOT 2
- Behave seems to Ignore `pyproject.toml` (in working directory) HOT 1
- vscode cucumber-language-sever: Quoted parameters in steps cause undefined-step in editor HOT 1
- PDF link in README.rst returns a 404 error HOT 1
- Bad type-converter pattern: MatchWithError is turned into AmbiguousStep HOT 3
- behave output with timestamp HOT 2
- Exception in test code during before_scenario causes exception in scenario.py HOT 4
- Negative time execution bug possible with use of freeze_time HOT 2
- How to add a formatter dynamically from environment.py
- Can behave integrate livingDoc, like SpecFlow + LivingDoc? HOT 2
- Support Background Steps with Placeholders for Scenario Outlines HOT 3
- No name 'given' in module 'behave' HOT 1
- Behave release schedule HOT 3
- Behave --parallel option HOT 3
- Trailing whitespace in lines of multiline text statements is stripped HOT 6
- Running Behave test with filestream instead of Feature File HOT 3
- When is the next release? I want to use enhancement #1185 . HOT 1
- OpenSSL internal error: FATAL FIPS SELFTEST FAILURE HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from behave.