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

worse and worse refactor new testing framework #927

Merged
merged 7 commits into from Mar 25, 2017
Merged

worse and worse refactor new testing framework #927

merged 7 commits into from Mar 25, 2017

Conversation

ghost
Copy link

@ghost ghost commented Mar 24, 2017

No description provided.

@drvinceknight
Copy link
Member

drvinceknight commented Mar 24, 2017

@alajara thanks for opening the PR :)

You've made the changes in a new file: test_worse_and_worse_v1.py. Can you make the changes directly on the original file ( test_worse_and_worse.py)? As we're using version control we will be able to see the changes and compare things.

Let us know if we can assist with anything :)

@ghost
Copy link
Author

ghost commented Mar 24, 2017

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

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

Copy link
Member

@drvinceknight drvinceknight left a 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 = \
Copy link
Member

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 = \
Copy link
Member

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 = \
Copy link
Member

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]), \
Copy link
Member

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 + \
Copy link
Member

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 = \
Copy link
Member

Choose a reason for hiding this comment

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

Same comment.

@drvinceknight
Copy link
Member

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 expected_actions you have input is not correct.

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 :)

alajara added 2 commits March 24, 2017 19:11
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
Copy link
Member

@drvinceknight drvinceknight left a 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 👍

@meatballs meatballs merged commit fd335ec into Axelrod-Python:master Mar 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants