Skip to content

Conversation

@roback
Copy link
Member

@roback roback commented Feb 18, 2016

To quote @dentarg in twingly/twingly-search-api-ruby#49 😄

Not the prettiest tests in the world, but now we actually check the result from the parsing.

Make the tests in the previous commit pass.

fix #18
At least I think its not needed. It works in python 2.7 without them.
Lets see what Travis has to say about it :).
fixture = open(file_path, 'r').read()
return fixture

def assert_blog_posts_equal(self, actual_post, expected_post):
Copy link
Contributor

Choose a reason for hiding this comment

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

How about implementing __eq__ on post instead. Seems to be pretty straight-foward:

def __eq__(self, other):
        return (isinstance(other, self.__class__)
            and self.__dict__ == other.__dict__)

See: http://stackoverflow.com/questions/390250/elegant-ways-to-support-equivalence-equality-in-python-classes

Copy link
Member Author

Choose a reason for hiding this comment

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

How about implementing eq on post instead.

TIL about __dict__ :)

One disadvantage is that it becomes impossible to find out whats wrong by looking at the test output:

AssertionError: 'Skvallernytt.se' != u'FEL'

# becomes:

AssertionError: <twingly_search.post.Post object at 0x10a8b76d0> != <twingly_search.post.Post object at 0x10a8b75d0>

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true.

@walro
Copy link
Contributor

walro commented Feb 18, 2016

Looks shippable to me.

@dentarg
Copy link
Contributor

dentarg commented Feb 18, 2016

:shipit:

roback added a commit that referenced this pull request Feb 18, 2016
@roback roback merged commit 6781fc2 into master Feb 18, 2016
@roback roback deleted the parser-tests branch February 18, 2016 16:05
roback added a commit that referenced this pull request Mar 3, 2016
* If Query#start_time and #end_time contains timezone information,
  convert it to UTC (#21)
* Parse post tags correctly (#19)
* Minor documentation improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants