question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Convert all tests to pytest

See original GitHub issue

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:

  • 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

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mattsb42-awscommented, Dec 18, 2018

No more unittest! 😃

Thanks for the help, @AndresSan6

0reactions
mattsb42-awscommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert all tests to pytest · Issue #468 - GitHub
Currently some tests are written in unit test and some in pytest. As pytest is more flexible all tests should be converted to...
Read more >
How to go about converting a test-suite from unittest to pytest?
There seems to be a conversion tool, though I haven't tested it. Generally, I would do this incrementally - if you want to...
Read more >
Effective Python Testing With Pytest
In this tutorial, you'll learn how to take your testing to the next level with pytest. You'll cover intermediate and advanced pytest ......
Read more >
How to use unittest-based tests with pytest
pytest supports running Python unittest -based tests out of the box. It's meant for leveraging existing unittest -based test suites to use pytest...
Read more >
Converting unittest suites to pytest - Packt Subscription
In the previous chapter, we have seen how the flexible pytest architecture has created a ... to large in-house-grown test suites that contain...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found