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

unit tests #79

Open
BurntSushi opened this issue May 26, 2014 · 4 comments
Open

unit tests #79

BurntSushi opened this issue May 26, 2014 · 4 comments

Comments

@BurntSushi
Copy link
Owner

This must be done before porting to Python 3. #78

Strategy to come shortly.

@leighlondon
Copy link
Contributor

What's the strategy you're thinking of for these tests?

@BurntSushi
Copy link
Owner Author

@leighlondon I've start some testing on nfldb here: https://github.com/BurntSushi/nfldb/tree/master/tests

For the most part, I want to test the API to make sure it is giving the results I expect it to give. There should be similar tests for nflgame.

(I don't consider unit tests as something which should test the validity of the data. That's another can of worms.)

@leighlondon
Copy link
Contributor

I'd be interested in adding some tests to this if it'd help out.

# tests/test_game.py
from nflgame.game import FieldPosition, PossessionTime

class TestPossessionTime:
    def test_minutes_to_total_seconds(self):
        clock = PossessionTime("5:00")
        assert clock.total_seconds() == 300
    # ...

class TestFieldPosition:
    def test_offset_redzone_yards_correct(self):
        fp = FieldPosition(yardline="NYJ 2", pos_team="NE")
        assert fp.offset == 48
    # ...

I take it you mean something like that for the API tests, so that it's data-agnostic but testing the base classes and functions?

@BurntSushi
Copy link
Owner Author

Yes, that looks reasonable. You can certainly rely on expecting certain data values for your tests.

Although, please use py.test. (It's really easy to use. Check out nfldb's tests.)

Thanks. :D

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

No branches or pull requests

2 participants