Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Parser tests - #19

Merged
roback merged 4 commits into
masterfrom
parser-tests
Feb 18, 2016
Merged

roback merged 4 commits into
masterfrom
parser-tests

Conversation

@roback

@roback roback commented Feb 18, 2016

Copy link
Copy Markdown
Member

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 :).
Comment thread tests/test_parser.py
fixture = open(file_path, 'r').read()
return fixture

def assert_blog_posts_equal(self, actual_post, expected_post):

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

walro commented Feb 18, 2016

Copy link
Copy Markdown
Contributor

Looks shippable to me.

@dentarg

dentarg commented Feb 18, 2016

Copy link
Copy Markdown
Contributor

: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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants