6

Testing Notebooks report the result of Plot as a Failure, when in fact it should be a Success.

enter image description here

Is there a way to fix this?

Chris K
  • 20,207
  • 3
  • 39
  • 74

2 Answers2

3

This is a similar issue to Testing Grids in a Testing Notebook and has the same solution: add a {SameTest -> (Rasterize[#1] == Rasterize[#2] &)}.

enter image description here

Seems related to the issue raised in Testing equality of graphics.

Chris K
  • 20,207
  • 3
  • 39
  • 74
  • 1
    +1. It does seem inconvenient to have to do this. (Note that rasterizing on tests approximate equality only. E.g. Rasterize[Plot[Sin[x] + 10^-5, {x, 0, 10}]] == Rasterize[Plot[Sin[x], {x, 0, 10}]].) – Michael E2 Feb 13 '18 at 16:41
  • I wonder why it fails. CellChangeTimes? Or something silly like that? Imo a bug. – ktm Feb 13 '18 at 16:47
3

Digging around using FullForm[]shows that the difference is a string-valued private tag

`Charting`Private`Tag$[random number]

Therefore, we may manually set that tag number to, say, 1 via a rule

nullRule = x_String /; StringMatchQ[x, "Charting`Private`Tag$*"] -> 
   "Charting`Private`Tag$1";

then the test runs okay:

enter image description here

egwene sedai
  • 2,355
  • 16
  • 24
  • also: does not work with pasted-in figure as expected output; also strongly suggest compare the data using, e.g. https://mathematica.stackexchange.com/questions/125222 – egwene sedai Feb 13 '18 at 19:11
  • See https://mathematica.stackexchange.com/questions/165652/testing-equality-of-graphics for the same solution and others. – Michael E2 Feb 13 '18 at 22:23