question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Added `echo` bool to capture.

See original GitHub issue

The capture method should have an echo parameter. When echo=True (the default) text should be captured and written to the terminal. When echo=False the text should be captured but not written to the terminal.

See https://github.com/Textualize/rich/issues/2172 for context.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SertugFcommented, Dec 6, 2022

Hello, i have been working on this. If echo is true by default it breaks the test below. Since new capture method prints all captured strings ‘out’ changes.

def test_capture_and_record(capsys):
    recorder = Console(record=True)
    recorder.print("ABC")

    with recorder.capture() as capture:
        recorder.print("Hello")

    assert capture.get() == "Hello\n"

    recorded_text = recorder.export_text()
    out, err = capsys.readouterr()

    assert recorded_text == "ABC\nHello\n"
    assert capture.get() == "Hello\n"
    assert out == "ABC\n"

terminal output : image

In order to pass previous tests should i just change default ‘echo’ value to ‘false’ ? Or does this test needs to be replaced ?

1reaction
darrenburnscommented, Jun 16, 2022

I think #2172 is unrelated to what actually gets written to the terminal and is instead about record=True not recording things that occur inside a Capture context. Doesn’t impact developing this feature, just thought I’d point it out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PHP - Get bool to echo false when false - Stack Overflow
Is there a better way to print 0 or false when $bool_val is false than adding an if statement? php · boolean ·...
Read more >
Booleans - Manual - PHP
The bool type only has two values, and is used to express a truth value. ... What will be the output you think...
Read more >
Boolean.prototype.toString() - JavaScript - MDN Web Docs
The toString() method returns a string representing the specified boolean value.
Read more >
PHP boolval() Function - W3Schools
Return the boolean value of different variables: <?php echo "0: " .(boolval(0) ? ... The boolval() function returns the boolean value of a...
Read more >
How to declare Boolean variables in bash and use them in a ...
Explains how to declare Boolean variables (True or False) in bash and ... echo 'Noop :(' fi # Double bracket format syntax to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found