Pythonwhat

Latest version: v2.24.4

Safety actively analyzes 638773 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 5 of 6

2.14.0

Changed

- If `PYTHONWHAT_V2_ONLY = '1'` is set as an environment variable, you can no longer use _any_ of the `test_` functions.
+ Instead of `Ex().test_or(...)`, you have to use `Ex().check_or(...)`.
+ Instead of `Ex().test_correct(...)`, you have to use `Ex().check_correct(...)`.
+ Instead of `test_mc()`, you have to use `Ex().has_chosen()`.
Docs have been updated accordingly.
- The package structure has been updated significantly
+ Distributing nearly all new functions over `check_funcs.py`, `has_funcs.py` and `check_logic.py`.
+ Grouping all old functions to test compound statements.
+ Moving around and rewriting tests to use `pytest` more and be more readable overall.

Fixed

- `test_not()`'s functionality was tested more and bugs that appeared were fixed.
It was nowhere used, so it was removed from the API in favor for `check_not()`, which has the same functionality.

Removed

- `extend()` can not be used anymore.
- `check_df()` can not be used anymore. UPDATE: added again in 2.14.2.

2.13.2

Changed

- The documentation pages have undergone significant maintenance.
+ There is now a tutorial that gradually exposes you to `pythonwhat`.
+ The articles have been brushed up to include more examples and more involved examples.
+ The articles have been split up into basic and advanced articles to make it clear what is most important.
+ `test_correct()` as a tool to add robustness is now featured more prominently

Fixed

- `set_context()` can now be used to specify arguments either by position, either by name, making it a great tool for flexible checking.
- For `has_equal_output()`, the message that was generated didn't always make sense. That is fixed now.
- Highlighting was removed in an SCT chain when `set_context()` was used. This is no longer the case.
- Small fixes for bugs that should not have impacted students in the first place.

2.13.1

2.13.0

Changed

- `test_function()` and `test_function_v2()` now use `check_function()` and `check_args()` behind the scenes.
That way, when we make improvements to the messaging logic, all SCTs that use any of these three functions will benefit from them.
In the future, we will deprecate `test_function()` and `test_function_v2()` as they are not explicit enough about what is being tested and how.
- `test_function('print')` and `check_function('print')` use `Ex().has_printout()` behind the scenes when appropriate.
This makes the SCTs much more accepting for different ways of doing printouts.
- You can now use `check_finalbody()` to check the `finally` part of a `try-except` block.
- Drastically improve `has_equal_ast()` messaging.
- If you manually specify `code` argument in `has_equal_ast()`, you _have_ to specify the `incorrect_msg` because the machine-generated one will be meaningless (for now).

Fixed

- **BIG ONE**: You can now test method calls that have subscripts in them.
This is particularly useful for `pandas`, where you for example want to test a call `df[df.b == 'x'].a.sum()`.
You can now do that with:

python
Check whether the function was called:
Ex().check_function('df.a.sum', signature=False)
Check whether the function was called and generated the correct result:
Ex().check_function('df.a.sum', signature=False).has_equal_value()


This update means that you should no longer need to use two `has_equal_ast()`'s inside a `test_correct()` to allow for two
different ways of doing a pandas operation. If you do, please create an issue!

- Some fixes to `has_printout()` that caused it not to work in all cases.
- `check_function()` now refers to a function call in the way that the student defined it.
When a student uses `import pandas as pd` and then has to call a function `pd.Series()`,
`check_function()` will refer to the function with `pd.Series()` and not `pandas.Series()`.

Removed

- `test_dict_comp()`, `test_try_except()`, `test_generator_exp()` and `test_lambda_function()` have been removed from the API.
The couple of SCTs on DataCamp that used these functions have been converted to use the modern `check_` functions.

2.12.6

Changed

- **If manually specifying `incorrect_msg` in has_equal_x: do not prepend previously generated messages. You no longer have to set `expand_msg = ""`.**

- Overall, improvement of automaticlaly generated messages:
+ Bite-size messages that are pasted together
+ More meaningful defaults that help (see `tests/test_messaging.py`)
+ Get rid of default-generated messages scattered all over the place
+ Better description of arguments
+ Better description of calls
+ Get rid of `has_key()` and `has_equal_key()` docs, as they will be phased out
+ Improved handling of getting results, output and values from process
+ Simplify old `test_expression_x()` functions and group in one file

2.12.4

Added

- You can now robustly test printouts with `Ex().has_printout(index = x)`. This function will look for the `x`'th `print()` call in the solution code, rerun that call while capturing the output, and then look for that output in the output that was generated by the student's code submission.

python
Ex().has_printout(index=0)


This approach is far easier and more robust than using `Ex().check_function().check_args().has_equal_value()`.


Changed

- Improvement in messages that are generated by default when checking `*args` and `**kwargs` arguments in function calls.

Fixed

- You can now use `test_or()` inside `test_correct()`:

python
Ex().test_correct(
check_object(...)
test_or(
check_function(...),
has_equal_ast(...)
)
)

Page 5 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.