Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dates() and times() strategies to hypothesis.extra.datetime #160

Merged
merged 1 commit into from Sep 28, 2015

Conversation

adamchainz
Copy link
Contributor

  • Add dates and times strategies
  • Add tests
  • Add documentation, improving datetimes documentation
  • Add livehtml target to docs/Makefile using sphinx-autobuild for live docs editing
  • gitignore update with some folders that appear during tests

@DRMacIver
Copy link
Member

Generally pretty strongly in favour of this feature, and assuming the build passes mostly looks good, thanks! I'll add some specific comments inline though.

@@ -276,6 +276,30 @@ def datetimes(allow_naive=None, timezones=None, min_year=None, max_year=None):
)


def dates(min_year=None, max_year=None):
Copy link
Member

Choose a reason for hiding this comment

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

hypothesis.strategies has a 'defines_strategy' decorator that should be used here that fixes up the repr of the returned strategy to correspond to the function that generates it. This should be used here and on times.

Copy link
Member

Choose a reason for hiding this comment

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

(I've just noticed I'm not using it on datetimes. I'll fix that)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@DRMacIver
Copy link
Member

LGTM. Will wait for the build and then assuming everything goes according to plan shall merge.

@DRMacIver
Copy link
Member

Ah, you've failed the linter. If you run tox -e lint locally this will fix up most of the errors.

@DRMacIver
Copy link
Member

The pypy segfault is not your fault and you should ignore it. Something I've done recently is triggering an intermittent pypy segfault. This is sadly a thing that happens.

@DRMacIver
Copy link
Member

Also you might want to rebase this against master, as there have been a few changes (one of which affects datetime).

@adamchainz
Copy link
Contributor Author

Linting and rebasing done.

@DRMacIver
Copy link
Member

Sorry, one final thing: You should add yourself to the list of contributors in CONTRIBUTING.rst :-)

@adamchainz
Copy link
Contributor Author

🎺 done

You now have TWO Adam Johnsons as contributors - suspicious...

@DRMacIver
Copy link
Member

Sorry, I said "finally" and then the build failed. :-(

The appveyor one is my fault (oops. Fixing now). The coverage one is I think you (not the strings case, which I've never seen fail before but looks like it can happen with very very low probability), but the datetimes one you haven't tested your argument validation for times().

One option there would be to just use the existing datetimes() function and inherit the argument validation from it rather than having to write your own.

DRMacIver added a commit that referenced this pull request Sep 28, 2015
Add dates() and times() strategies to hypothesis.extra.datetime
@DRMacIver DRMacIver merged commit c07e240 into HypothesisWorks:master Sep 28, 2015
@DRMacIver
Copy link
Member

Sorry, I missed the final fix on this had happened.

Thanks again for the feature!

@adamchainz
Copy link
Contributor Author

🌈 😸

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.

None yet

2 participants