As by default, when executing tests with -C opt-level=n where "n" is greater than 0, debug assertions are disabled, which removes the panic!() this test is expecting. With this tweak, tests no longer fail with any choice of -C opt-level, and additionally, tests still execute correctly if these tests are compiled with: -C opt-level=3 -C debug-assertions=yes Closes: https://github.com/seanmonstar/reqwest/issues/831