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: ExUnit.Formatter — ExUnit v1.20.2

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
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
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement