Skip to content

Convert all tests to pytest #99

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

Closed
16 tasks done
mattsb42-aws opened this issue Nov 13, 2018 · 9 comments
Closed
16 tasks done

Convert all tests to pytest #99

mattsb42-aws opened this issue Nov 13, 2018 · 9 comments

Comments

@mattsb42-aws
Copy link
Member

mattsb42-aws commented Nov 13, 2018

A lot of the original test suite was written in unittest. Let's get all of that moved over to pytest.

Initially, this should be converting unittest.TestCase classes to pytest classes similar to what was done in #98. We can pull those methods out to stand-alone functions later if we decide we want to, but leaving them in classes will make the diffs most simpler.

I would also like to opportunistically remove some of the over-zealous mocking present in these classes where we can.

Test modules to convert:

Due to the changes that will need to happen, anyone looking at this please follow the following guidelines:

  1. Convert from unittest classes to classes using pytest first. We can change to functions later if desired, but converting the classes directly will minimize the changes in each test file.
  2. One test file per PR. This will minimize the amount of changes that need to be reviewed and speed up the review process.
  3. Run tox -re autoformat before committing to apply our formatting rules.
@ansanper
Copy link
Contributor

ansanper commented Dec 12, 2018

Hello! I can help with this issue, I will start working on it.

@mattsb42-aws
Copy link
Member Author

Hi, @AndresSan6. That would be awesome, thanks! We would love any help you want to contribute.

One thing I would ask, since we haven't gotten around to setting up pre-commit hooks yet: please make sure you run tox -re autoformat before each commit (or at least before submitting the PR). This applies black and isort to the codebase.

@ansanper
Copy link
Contributor

I already made the pull request for each test, in the following list I share their PR number.

test/integration/test_i_aws_encrytion_sdk_client.py #114
test/unit/test_aws_encryption_sdk.py #115
test/unit/test_defaults.py #116
test/unit/test_deserialize.py #117
test/unit/test_encryption_context.py #118
test/unit/test_providers_base_master_key.py #119
test/unit/test_providers_base_master_key_provider.py #120
test/unit/test_providers_kms_master_key.py #121
test/unit/test_providers_kms_master_key_provider.py #122
test/unit/test_providers_raw_master_key.py #123
test/unit/test_providers_raw_master_key_provider.py #124
test/unit/test_serialize.py #125
test/unit/test_streaming_client_stream_decryptor.py #126
test/unit/test_streaming_client_stream_encryptor.py #127
test/unit/test_util_str_ops.py #128
test/unit/test_utils.py #129

Please let me know if these changes help you.

@mattsb42-aws
Copy link
Member Author

Awesome, thanks! I'll start working through those today and Monday.

@mattsb42-aws
Copy link
Member Author

mattsb42-aws commented Dec 15, 2018

@AndresSan6 Looks like a lot of these are choking on linting checks. To check that locally, you can just run: tox -re "{flake8,pylint}-tests".

So far they mostly just need now-unused imports removed.

@mattsb42-aws
Copy link
Member Author

These look great; exactly what I was looking for!

There are two issues that affect several of these (I noted in each PR where each affects which):

@ansanper
Copy link
Contributor

Got i! I will start solving the addressed issues. I will let you know when I committed my changes.

@mattsb42-aws
Copy link
Member Author

mattsb42-aws commented Dec 17, 2018

Looks like a couple had lingering minor linting issues. Just a reminder that tox -e autoformat should clear up most of those.

@mattsb42-aws
Copy link
Member Author

No more unittest! :)

Thanks for the help, @AndresSan6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants