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: PYTEST output #22290

Closed
3 tasks done
eleanorjboyd opened this issue Oct 23, 2023 · 2 comments
Closed
3 tasks done

TPI: PYTEST output #22290

eleanorjboyd opened this issue Oct 23, 2023 · 2 comments
Labels
testplan-item Test plan item/assignments for upcoming release
Milestone

Comments

@eleanorjboyd
Copy link
Member

eleanorjboyd commented Oct 23, 2023

Refs: 21861

Complexity: 4

Author: @eleanorjboyd

Create Issue

Create Issue


Thank you for doing this testing!

Setup

1. Clone the test repo from [[here](https://github.com/eleanorjboyd/inc_dec_example_repo)](https://github.com/eleanorjboyd/inc_dec_example_repo) 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. (for pytest)
    1. In the terminal, run `python -m pip install pytest`.
    2. From the command palette, run "python: configure tests", select `pytest` and then "." (root directory)
6. click the test explorer icon (beaker)
7. configure tests
    1. pytest: pytest → root
  1. Testing:
    1. in your settings.json you should see a "python.testing.pytestArgs": [] make the following changes and see the desired output. Output will be in the Test Results panel unless stated otherwise

Testing Output TPI specifics

  1. Add --color=yes
    1. check to see if the results are in color
  2. switch to using log level error
    1. check to see that only error and critical logs show up (change back after)
  3. in the test result panel click on a failed test item
    1. check that you can see a stack trace of sorts about the failed test
  4. change test assert to assert True
    1. check that printing and logging does not appear
  5. Add ["-o", "log_cli=true"], and keep assert True
    1. check that logging now occurs
  6. From the terminal run python -m pytest test_logging.py and make sure it looks the same as it looks when you run just test_logging.py from the test explorer

Non execution related tests

  1. Add -v to the args, set vscode log level to trace , then check in the “python” logs that you can see the list of tests discovered

something like the following:

<Module outer_nested_folder/test_outer_folder.py>
  <Function test_outer_folder1>
  <Function test_outer_folder2>
<Module outer_nested_folder/inner_nested_folder/test_nested.py>
  <Function test_answer_1pNest>
<Module outer_nested_folder/inner_nested_folder/test_unittest.py>
  <UnitTestCase test_class_unittest>
  1. switch to “python test logs” confirm you see a deprecation message
@eleanorjboyd eleanorjboyd added the testplan-item Test plan item/assignments for upcoming release label Oct 23, 2023
@jrieken jrieken removed their assignment Oct 24, 2023
@amunger
Copy link

amunger commented Oct 24, 2023

switch to using log level error

Is this just the python logging level in settings or is there a pytest argument to do this? I don't see any difference when using the python log level setting

@eleanorjboyd
Copy link
Member Author

@amunger this should be in the code in the test so switching the following lines. Sorry that was unclear!

# caplog.set_level(logging.DEBUG)  # Debug level
    caplog.set_level(logging.ERROR)  # Error level

@rzhao271 rzhao271 removed their assignment Oct 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
testplan-item Test plan item/assignments for upcoming release
Projects
None yet
Development

No branches or pull requests

5 participants