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

Improve our test for reset and fix some test bugs. #1098

Merged
merged 7 commits into from
Jul 30, 2017

Conversation

drvinceknight
Copy link
Member

We were only playing against Random, @marcharper found and fixed a bug via
hypothesis on it here:
#1097

This catches the bug too:

Axelrod(pass-match-attributes) ✗: python -m unittest
axelrod.tests.strategies.test_titfortat
...............................................................................F................................................................
======================================================================
FAIL: test_reset_history_and_attributes
(axelrod.tests.strategies.test_titfortat.TestNTitsForMTats)
Make sure resetting works correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File
  "/home/vince/src/Axelrod/axelrod/tests/strategies/test_player.py",
  line 411, in test_reset_history_and_attributes
      self.assertEqual(player, clone)
      AssertionError: N Tit(s) For M Tat(s): 3, 2 != N Tit(s) For M
      Tat(s): 3, 2

@drvinceknight
Copy link
Member Author

drvinceknight commented Jul 29, 2017

This has now caught a few other bugs. Thankfully they are only bugs in our tests:

A number of tests for stochastic strategies were not seeded, and I offset the seed in my test update. Essentially this fixes those tests.

@drvinceknight
Copy link
Member Author

This is a fork of #1097 (as one of the bugs is fixed there).

@drvinceknight drvinceknight changed the title Improve our test for reset. Improve our test for reset and fix some test bugs. Jul 29, 2017
We were only playing against Random, @marcharper found and fixed a bug via
hypothesis on it here:
#1097

This catches the bug too:

Axelrod(pass-match-attributes) ✗: python -m unittest
axelrod.tests.strategies.test_titfortat
...............................................................................F................................................................
======================================================================
FAIL: test_reset_history_and_attributes
(axelrod.tests.strategies.test_titfortat.TestNTitsForMTats)
Make sure resetting works correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File
  "/home/vince/src/Axelrod/axelrod/tests/strategies/test_player.py",
  line 411, in test_reset_history_and_attributes
      self.assertEqual(player, clone)
      AssertionError: N Tit(s) For M Tat(s): 3, 2 != N Tit(s) For M
      Tat(s): 3, 2
This just changes the name of the test so that the default test is not
used.
Meta is a random strategy but the test was not seeded.
It is a random strategy, that will act randomly if `-1<f<1`, `f` is
calculated as the sin(...), at the start of that game, it is sin(0)
which means it acts randomly from the start.
It was passing (by luck) and actually was a test for a case that is
tested lower down anyway (it's when the strategy's score is low).

# Check for -0.3 < f < 0.3, random
actions = [(D, C), (C, C), (D, C), (D, C),
(C, C), (D, C)] + [(C, C)] * 6 + [(D, C),(D, C)] + [(C, C)] * 7
self.versus_test(opponent=axelrod.MockPlayer(actions=[C]), expected_actions=actions, seed=6)
self.versus_test(opponent=axelrod.MockPlayer(actions=[C]),
Copy link
Member

Choose a reason for hiding this comment

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

Can we use cooperator and defector for these tests?

@marcharper
Copy link
Member

Looks fine to me, just a comment about using Cooperator and Defector if possible.

@drvinceknight
Copy link
Member Author

Looks fine to me, just a comment about using Cooperator and Defector if possible.

Good call. Done. 👍

@marcharper marcharper merged commit 2d0e2c6 into master Jul 30, 2017
@drvinceknight drvinceknight deleted the better-reset-test branch July 30, 2017 15:19
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.

None yet

3 participants