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

Standardize tests for memoryone and memorytwo files. #1333

Merged
merged 1 commit into from
Jun 5, 2020

Conversation

gaffney2010
Copy link
Member

The memoryone and memorytwo strategy files were doing some unusual things in the test files. It seems like they were trying to duplicate some functionality in Player's repr and in TestPlayers tests. This was causing problems with Classifiers logic. Details:

Code was changing name on initialization to include the parameter that the strategy was used with. name is only used in two places: for repr and for Classifiers. repr already attaches the initialization parameters, and Classifiers was getting messed up because instances had a different name than the class. By making this change we make the strategy behave consistently with other strategies.

I removed test_name from these unittests because this is covered by test_repr in TestPlayer. It's true that test_play in these tests covers repr for strategies initialized with specific parameters, but we can rely on the unittests that cover a general Player's repr logic.

I removed classifier tests in these files. We see in #1330 that we had to update classifier tests. We can update here too, but it'd be redundant and hard to maintain to continue to have these tests listed special.

@gaffney2010 gaffney2010 reopened this Apr 16, 2020
@marcharper
Copy link
Member

So IIUC these tests are redundant since

    def test_repr(self):
        """Test that the representation is correct."""
        if self.__class__ != TestPlayer:
            self.assertEqual(str(self.player()), self.name)

acts on instances. Is it similarly the case for whether these strategies are stochastic or not?

@gaffney2010
Copy link
Member Author

Yes. The test you quoted tests that a strategy with no initialization parameters will just equal the name. There logic in the base Player class that appends initialization parameters. This is tested too, but not for every strategy. The repr tests I deleted cover the second case for specific strategies.

As well, I deleted tests that check the classifier on these strategies, which is also redundant because of tests in TestPlayer.

@meatballs meatballs merged commit 894ebb7 into Axelrod-Python:master Jun 5, 2020
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