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

TPI: Python testing using new EOT token PYTEST #22080

Closed
3 tasks done
eleanorjboyd opened this issue Sep 26, 2023 · 2 comments
Closed
3 tasks done

TPI: Python testing using new EOT token PYTEST #22080

eleanorjboyd opened this issue Sep 26, 2023 · 2 comments

Comments

@eleanorjboyd
Copy link
Member

eleanorjboyd commented Sep 26, 2023

Refs: #21876

Complexity: 4

Author: @eleanorjboyd

Create Issue


Thank you for doing this testing! I apologize for how long it is and please let me know if you have any questions!

  1. Setup:

    1. Clone the test repo from here or use your own repo of pytests.
    2. Launch VSCode and open the inc_dec_example_repo/inc_dec_example_test_suite testing repo folder.
    3. Add the following to your settings in VSCode: "python.experiments.optInto": ["pythonTestAdapter"],
    4. Use the "create environment" command from the command palette, select venv and a Python version >=3.7.
    5. In the terminal, run python -m pip install pytest.
    6. From the command palette, run "python: configure tests", select pytest and then "." (root directory)
  2. General:

    1. Run the tests and then cancel the test run. Check that there are no spinning icons indicating unresolved actions.
    2. Debug the tests, then cancel. Again, ensure no spinning icons appear. You should try canceling using both the stop button in the test explorer panel and in the debug controller.
    3. Execute a large number of tests to ensure that the test run completes.
    4. Verify that test run and logging function correctly by referring to test_logging.py. Ensure that ALL the expected output gets printed. Compare the output in VSCode with what you get when running pytest directly from the command line for the test_logging file.
    5. Run a test that has a segmentation fault, make sure it resolves correctly and displays a helpful message.
@lszomoru
Copy link
Member

Run a test that has a segmentation fault, make sure it resolves correctly and displays a helpful message.

Any guidance on how to do this would be really valuable. Thanks!

@joaomoreno
Copy link
Member

From ChatGPT:

Causing a segmentation fault in Python intentionally is not recommended, as it can lead to unpredictable behavior and potentially harm your system or data. Segmentation faults typically occur when a program tries to access a memory location that it doesn't have permission to access. However, if you are doing this for educational or debugging purposes, you can force a segmentation fault in Python using the ctypes library and some low-level C code. Here's how you can do it:

import ctypes

# Attempt to access an invalid memory location
ctypes.string_at(0)

When you run this code, it will most likely result in a segmentation fault and crash the Python interpreter.

Again, please be cautious when intentionally causing segmentation faults, as it can have unintended consequences and may lead to system instability. It's always better to handle errors gracefully in your code rather than intentionally crashing it.

@lszomoru lszomoru removed their assignment Sep 26, 2023
@connor4312 connor4312 removed their assignment Sep 26, 2023
@karthiknadig karthiknadig removed their assignment Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants