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.

Print collections of long strings over multiple lines

See original GitHub issue

Discussed in https://github.com/fluentassertions/fluentassertions/discussions/1722

<div type='discussions-op-text'>

Originally posted by rcdailey October 27, 2021 When I have a BeEquivalentTo() comparison between two lists of strings, the output looks like this:

Expected DynamicMenuTestHelpers.FixupCaptions(menu.ItemLinks) to be a collection with 4 item(s), but {"Generate Report (DR Objects)", "Generate Report (Non-DR Objects)"}"
"contains 2 item(s) less than"
"{"Schedule Disaster Recovery Backups...", "Run Backup Now", "Generate Report (DR Objects)", "Generate Report (Non-DR Objects)"}.

I personally find this difficult to read, mainly because everything is on one line. Is there a way to make this print out “prettier”? Something as simple as one string per line I think might make this more legible.</div>

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
rcdaileycommented, Nov 5, 2021

Along the lines of making this more “Readable”, I thought of another idea:

Instead of saying:

Expected a list of 4 items:
  - "Apple"
  - "Banana"
  - "Cantaloupe"
  - "Durian"

But got 2 instead:
  - "Apple"
  - "Durian"

Instead, just show what is missing:

Expected a list of 4 items, but the following 2 are missing:
  - "Banana"
  - "Cantaloupe"

This is shorter, easier to read, and a little less confusing. I personally am only interested in what is missing. I usually look at the unit test code anyway to see what was there. Maybe there’s a different set of valid use cases for both, so I’d also be happy with the “delta” version of this (the bottom example) being an opt-in feature.

So really I’d boil down this issue into two main parts:

  • Make what is there more readable by breaking up lists of items into multiple lines
  • Reduce the “boilerplate” text in the assertion failure to focus more on what is missing, rather than what is present, as I believe that is more helpful to resolving test failures.

Thank you for being so open minded about my suggestions! Love the library!!

2reactions
rcdaileycommented, Jul 20, 2023

@Constante-ou-Mort The FluentAssertions developers are likely not paid to do work here, nor do they work for you. Respectfully, if you want to see change, it would be far more productive to fork the repository and contribute code. If you aren’t willing to do that, the best you can do is thumbs up the issue and move on. Your comments are a distraction to the developers and to others subscribed to this issue to be notified of meaningful updates.

I apologize that my tone seems aggressive or rude; I only intend to be frank. I hope you understand. It’s hard for me to wait too, but that’s open source.

To the maintainers: My feelings wouldn’t be hurt if you decided to lock conversation on this issue to maintainers only.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I split the definition of a long string over multiple ...
Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash...
Read more >
Write a long string on multiple lines in Python - nkmk note
This article explains how to break a long string into multiple lines without including a newline character. Contents.
Read more >
Write a Long String on Multiple Lines in Python
This method allows you to include line breaks and special characters like newline characters directly in the string without using escape ...
Read more >
Python Multiline Strings
You can assign a multiline string to a variable by using three quotes: ... print(a). Try it Yourself ». Note: in the result,...
Read more >
How Can I Define Multiline String In Python
The simplest way to do it is to enclose the entire string with three sets of double quotes: e.g.
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