Skip to content

docs: Add setup instructions to run/debug tests locally #153

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

Merged
merged 4 commits into from
Aug 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ information to effectively respond to your bug report or contribution.
* [Contributing via Pull Requests (PRs)](#contributing-via-pull-requests-prs)
* [Pulling Down the Code](#pulling-down-the-code)
* [Running the Unit Tests](#running-the-unit-tests)
* [Running Unit Tests and Debugging in PyCharm](#running-unit-tests-and-debugging-in-pycharm)
* [Running the Integration Tests](#running-the-integration-tests)
* [Making and Testing Your Change](#making-and-testing-your-change)
* [Committing Your Change](#committing-your-change)
* [Sending a Pull Request](#sending-a-pull-request)
* [Finding Contributions to Work On](#finding-contributions-to-work-on)
* [Setting Up Your Development Environment](#setting-up-your-development-environment)
* [Setting Up Your Environment for Debugging](#setting-up-your-environment-for-debugging)
* [PyCharm](#pycharm)
* [Code of Conduct](#code-of-conduct)
* [Security Issue Notifications](#security-issue-notifications)
* [Licensing](#licensing)
Expand Down Expand Up @@ -65,6 +69,11 @@ You can also run a single test with the following command: `tox -e py36 -- -s -v
* Note that the coverage test will fail if you only run a single test, so make sure to surround the command with `export IGNORE_COVERAGE=-` and `unset IGNORE_COVERAGE`
* Example: `export IGNORE_COVERAGE=- ; tox -e py36 -- -s -vv tests/unit/test_sagemaker_steps.py::test_training_step_creation_with_model ; unset IGNORE_COVERAGE`

#### Running Unit Tests and Debugging in PyCharm
You can also run the unit tests with the following options:
* Right click on a test file in the Project tree and select `Run/Debug 'pytest' for ...`
* Right click on the test definition and select `Run/Debug 'pytest' for ...`
* Click on the green arrow next to test definition

### Running the Integration Tests

Expand Down Expand Up @@ -168,6 +177,33 @@ Please remember to:
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/aws-step-functions-data-science-sdk-python/labels/help%20wanted) issues is a great place to start.


## Setting Up Your Development Environment

### Setting Up Your Environment for Debugging

Setting up your IDE for debugging tests locally will save you a lot of time.
You might be able to `Run` and `Debug` the tests directly in your IDE with your default settings, but if it's not the case,
follow the steps described in this section.

#### PyCharm
1. Set your Default test runner to `pytest` in _Preferences → Tools → Python Integrated Tools_
1. If you are using `PyCharm Professional Edition`, go to _Preferences → Build, Execution, Deployment → Python Debugger_ and set the options with following values:

| Option | Value |
|:------------------------------------------------------------ |:----------------------|
| Attach subprocess automatically while debugging | `Enabled` |
| Collect run-time types information for code insight | `Enabled` |
| Gevent compatible | `Disabled` |
| Drop into debugger on failed tests | `Enabled` |
| PyQt compatible | `Auto` |
| For Attach to Process show processes with names containing | `python` |

This will allow you to break into all subprocesses of the process being debugged and preserve functions types while debugging.
1. Debug tests in PyCharm as per [Running Unit Tests and Debugging in PyCharm](#running-unit-tests-and-debugging-in-pycharm)

_Note: This setup was tested and confirmed to work with
`PyCharm 2020.3.5 (Professional Edition)` and `PyCharm 2021.1.1 (Professional Edition)`_

## Code of Conduct

This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
Expand Down