-
Notifications
You must be signed in to change notification settings - Fork 263
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
worse and worse refactor new testing framework #927
Conversation
@alajara thanks for opening the PR :) You've made the changes in a new file: Let us know if we can assist with anything :) |
Sorry about the name change, fixed it. If there is anything else wrong please let me know. Thanks |
@@ -1,11 +1,10 @@ | |||
"""Tests for the WorseAndWorse strategies.""" | |||
|
|||
import axelrod | |||
from .test_player import TestPlayer | |||
from test_player import TestPlayer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are currently failing because of this change. You need to change it back to:
from .test_player import TestPlayer
If you wanted to run the tests locally you can do this by typing the following at the command line from the root of the Axelrod directory:
$ python -m unittest axelrod.tests.unit.test_worse_and_worse
More information about that here: http://axelrod.readthedocs.io/en/latest/tutorials/contributing/strategy/running_tests.html
Update test_worse_and_worse.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more stylistic/PEP8 requests.
('C', 'D')]) | ||
|
||
actions = [(C, C)] + [(D, C)] * 4 | ||
self.versus_test(axelrod.Cooperator(), expected_actions = \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this and similar lines to be:
self.versus_test(axelrod.Cooperator(), expected_actions = actions,
match_attributes={"length":5}, seed=1)
('D', 'C'), | ||
('D', 'C')]) | ||
actions = [(C, D)] + [(D, D)] * 4 | ||
self.versus_test(axelrod.Defector(), expected_actions = \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same request about \
|
||
# Test that behaviour changes when does not know length. | ||
actions = [(C, C), (C, D), (C, C), (C, D), (C, C)] | ||
self.versus_test(axelrod.Alternator(), expected_actions = \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same request.
= actions) | ||
|
||
actions = [(C, C), (C, C), (C, D),(D, C)] | ||
self.versus_test(opponent=axelrod.MockPlayer([C,C,D,C]), \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment
expected_actions=actions) | ||
|
||
actions = [(C, C)] * 18 + [(C, D), (D, C)] | ||
self.versus_test(opponent=axelrod.MockPlayer([C] * 18 + \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment
expected_actions=actions, seed=8) | ||
|
||
actions = [(D, D)] * 3 + [(C, D)] * 2 + [(D, D)] * 3 + [(C, C)] | ||
self.versus_test(axelrod.MockPlayer([D] * 5), expected_actions = \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment.
The tests are not correct, we can see this because we're getting a failure on the automatic run of the tests. Here is the output of the failing test that I've just copied: File "/home/travis/build/Axelrod-Python/Axelrod/axelrod/tests/strategies/test_player.py", line 364, in versus_test
self.assertEqual(match.play(), expected_actions)
AssertionError: Lists differ: [('C', 'D'), ('D', 'D'), ('D', 'D'), ('D', '[59 chars]'D')] != [('D', 'D'), ('D', 'D'), ('D', 'D'), ('C', '[59 chars]'C')]
First differing element 0:
('C', 'D')
('D', 'D')
- [('C', 'D'),
? ^
+ [('D', 'D'),
? ^
+ ('D', 'D'),
+ ('D', 'D'),
+ ('C', 'D'),
+ ('C', 'D'),
('D', 'D'),
('D', 'D'),
('D', 'D'),
- ('D', 'D'),
- ('D', 'D'),
- ('D', 'D'),
- ('D', 'D'),
- ('D', 'D')]
? ^ ^
+ ('C', 'C')] That's pointing out that one of the I can take a closer look at this over the Weekend and help a bit more (right now I really need to try and finish some marking :)) but otherwise I suggest running the tests locally and identifying the correct behaviour. We'll get this in soon :) |
I deleted the last test for the class worse and worse 3, the test before it test the given seed for a 0/1 probability of defecting. The deleted was giving the same result as the prior Defector test . I went ahead and fixed the other corrections and ran the unitteest on each class, all checked out. HopefullyI am getting all the kinks out now, and my next PR's hopefully are a lot better.
Update test_worse_and_worse.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me @alajara! Thanks for the contribution.
We have a two core member peer review system so one of the other core developers will be along when they get a moment :)
Looking forward to your next one 👍
No description provided.