Skip to content

Stop gap solution for long output on test cases - #45882

Merged
tenderlove merged 2 commits into
mainfrom
short-inspect-on-test-case
Aug 24, 2022
Merged

tenderlove merged 2 commits into
mainfrom
short-inspect-on-test-case

Conversation

@tenderlove

Copy link
Copy Markdown
Member

This patch just changes the inspect method on test case instances.
Seeing test instance internals probably isn't helpful when an exception
is raised (for example a NoMethodError).

This isn't as good as #45122, but should fix #45121

I don't think this is great, but should fix the immediate pain. This does make me think we should have an API in Ruby for telling inspect what instance variables we would like it to use.

The implementation of inspect simply loops over all instance variables, but interestingly it doesn't call the instance_variables method to determine what IVs to inspect.

To me, it feels like these two objects should have different inspect output, but they don't:

class Foo
  def initialize
    @foo = 1
    @bar = 1
  end
end

class Bar < Foo
  def instance_variables
    [:@foo]
  end
end

p Foo.new
p Bar.new

Anyone have any thoughts on this PR or the above thing? I'm happy to file a redmine ticket wrt the inspect feature.

This patch just changes the inspect method on test case instances.
Seeing test instance internals probably isn't helpful when an exception
is raised (for example a `NoMethodError`).

This isn't as good as #45122, but should fix #45121

@byroot byroot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me as a quick fix than we can easily backport until the full solution comes around.

Comment thread activesupport/lib/active_support/test_case.rb Outdated
Co-authored-by: John Hawthorn <john@hawthorn.email>
@tenderlove
tenderlove merged commit fd9308a into main Aug 24, 2022
@tenderlove
tenderlove deleted the short-inspect-on-test-case branch August 24, 2022 20:45
tenderlove added a commit that referenced this pull request Aug 24, 2022
Stop gap solution for long output on test cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Very long test output even for simple failing tests

3 participants