sunaku

sunaku

Assertion with == failed: How to disable truncation? (limit infinity)

Hello,

How can I prevent ExUnit from truncating the left and right values in an assertion failure with “…” ellipses? :thinking: Does ExUnit have a configuration option like limit: :infinity for IO.inspect()?

  1) test encode() single (EncoderTest)
     test/encoder_test.exs:25
     Assertion with == failed
     code:  assert actual == expected
     left:  <<87, 0, 0, 0, 2, 95, 105, 100, 0, 7, 0, 0, 0, 115, 99, 104, 101,
              109, 97, 0, 2, 118, 101, 114, 115, 105, 111, 110, 0, 6, 0, 0, 0,
              49, 46, 49, 46, 51, 0, 2, 103, 101, 110, 101, 114, 97, 116, 111,
              114, 0, ...>>
     right: <<109, 0, 0, 0, 2, 95, 105, 100, 0, 7, 0, 0, 0, 115, 99, 104, 101,
              109, 97, 0, 2, 118, 101, 114, 115, 105, 111, 110, 0, 6, 0, 0, 0,
              49, 46, 49, 46, 51, 0, 2, 103, 101, 110, 101, 114, 97, 116, 111,
              114, 0, ...>>
     stacktrace:
       test/encoder_test.exs:43: (test)

Currently, I’m having to manually inspect the contents of my binary data strings with IO.inspect(limit: :infinity) so that I can see them printed in their entirety for manual visual comparison: :weary:

actual = binary1 |> IO.inspect(label: "actual", limit: :infinity)
expected = binary2 |> IO.inspect(label: "expected", limit: :infinity)
assert actual == expected

Thanks for your consideration.

Marked As Solved

devonestes

devonestes

At the moment it looks like the default CLI formatter for ExUnit does not have a way to display diffs with an infinite size because it uses IO.puts/2, and that function doesn’t have all the same options that IO.inspect/3 takes. It’s totally possible to write and use a separate formatter if one wanted to do that. The docs on how to do that are here: https://hexdocs.pm/ex_unit/ExUnit.Formatter.html

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement