Skip to content

Commit 6b62bf7

Browse files
ca-nguyenshivlaks
andauthored
docs: Add setup instructions to run/debug tests locally (aws#153)
* docs: Add setup instructions to run/debug tests locally Co-authored-by: Shiv Lakshminarayan <[email protected]>
1 parent ac652ab commit 6b62bf7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

CONTRIBUTING.md

+36
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ information to effectively respond to your bug report or contribution.
1414
* [Contributing via Pull Requests (PRs)](#contributing-via-pull-requests-prs)
1515
* [Pulling Down the Code](#pulling-down-the-code)
1616
* [Running the Unit Tests](#running-the-unit-tests)
17+
* [Running Unit Tests and Debugging in PyCharm](#running-unit-tests-and-debugging-in-pycharm)
1718
* [Running the Integration Tests](#running-the-integration-tests)
1819
* [Making and Testing Your Change](#making-and-testing-your-change)
1920
* [Committing Your Change](#committing-your-change)
2021
* [Sending a Pull Request](#sending-a-pull-request)
2122
* [Finding Contributions to Work On](#finding-contributions-to-work-on)
23+
* [Setting Up Your Development Environment](#setting-up-your-development-environment)
24+
* [Setting Up Your Environment for Debugging](#setting-up-your-environment-for-debugging)
25+
* [PyCharm](#pycharm)
2226
* [Code of Conduct](#code-of-conduct)
2327
* [Security Issue Notifications](#security-issue-notifications)
2428
* [Licensing](#licensing)
@@ -65,6 +69,11 @@ You can also run a single test with the following command: `tox -e py36 -- -s -v
6569
* 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`
6670
* Example: `export IGNORE_COVERAGE=- ; tox -e py36 -- -s -vv tests/unit/test_sagemaker_steps.py::test_training_step_creation_with_model ; unset IGNORE_COVERAGE`
6771

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

6978
### Running the Integration Tests
7079

@@ -168,6 +177,33 @@ Please remember to:
168177
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.
169178
170179
180+
## Setting Up Your Development Environment
181+
182+
### Setting Up Your Environment for Debugging
183+
184+
Setting up your IDE for debugging tests locally will save you a lot of time.
185+
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,
186+
follow the steps described in this section.
187+
188+
#### PyCharm
189+
1. Set your Default test runner to `pytest` in _Preferences → Tools → Python Integrated Tools_
190+
1. If you are using `PyCharm Professional Edition`, go to _Preferences → Build, Execution, Deployment → Python Debugger_ and set the options with following values:
191+
192+
| Option | Value |
193+
|:------------------------------------------------------------ |:----------------------|
194+
| Attach subprocess automatically while debugging | `Enabled` |
195+
| Collect run-time types information for code insight | `Enabled` |
196+
| Gevent compatible | `Disabled` |
197+
| Drop into debugger on failed tests | `Enabled` |
198+
| PyQt compatible | `Auto` |
199+
| For Attach to Process show processes with names containing | `python` |
200+
201+
This will allow you to break into all subprocesses of the process being debugged and preserve functions types while debugging.
202+
1. Debug tests in PyCharm as per [Running Unit Tests and Debugging in PyCharm](#running-unit-tests-and-debugging-in-pycharm)
203+
204+
_Note: This setup was tested and confirmed to work with
205+
`PyCharm 2020.3.5 (Professional Edition)` and `PyCharm 2021.1.1 (Professional Edition)`_
206+
171207
## Code of Conduct
172208

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

0 commit comments

Comments
 (0)