What's New in Vedro v1.12
We are excited to announce the release of Vedro v1.12, bringing several new features and enhancements designed to improve your testing experience. Let's dive into the details of this update.
New Assertions with Beautiful Diffs
Enhanced AssertionError Output
We've introduced new assertions that provide beautiful and informative diffs, making it easier to spot differences between expected and actual values.
AssertionError
>>> assert actual == expected
{
- 'task_id': 1,
+ 'task_id': 2,
'description': 'Implement user authentication system',
...
'assignee': 'Bob',
- 'due_date': '2024-07-14'
+ 'due_date': '2024-07-15'
}
# --seed 69a72e09-1556-4cd7-b13a-895797bd2cd0
# 1 scenario, 0 passed, 1 failed, 0 skipped (0.10s)
Full Diff Display
For more detailed output, use the --show-full-diff
argument to see the complete diff of the assertions.
$ vedro run --show-full-diff
AssertionError
>>> assert actual == expected
{
'total': 1,
'items': [
{
- 'task_id': 1,
+ 'task_id': 2,
'description': 'Implement user authentication system',
'status': 'in progress',
'assignee': 'Bob',
- 'due_date': '2024-07-14'
+ 'due_date': '2024-07-15'
}
]
}
# --seed afa8aad3-0a43-44f1-b12c-cbfa9c57ee63
# 1 scenario, 0 passed, 1 failed, 0 skipped (0.10s)
If you prefer the old behavior, you can use the --legacy-assertions
argument.
New Command-Line Arguments
Change Project Directory
The --project-dir
argument allows you to specify the root directory of your project, providing a reference point for relative paths and file operations. By default, it uses the directory from which the command is executed.
$ vedro run --project-dir /app/tests
Enhancements to RichReporter
Suppress Modules in Traceback
The tb_suppress_modules
parameter allows you to suppress specific modules in the traceback output, making the relevant information more prominent.
# vedro.cfg.py
class RichReporter(vedro.plugins.director.rich.RichReporter):
tb_suppress_modules = [json]
- Suppressed
- Not Suppressed
Scenarios
*
✗ login as user
✔ given_user_creds
✔ when_user_logins
✔ then_it_should_return_ok_status
✗ and_it_should_return_json_body
╭───────────────────── Traceback (most recent call last) ───────────────────╮
│ /tests/scenarios/login_as_user.py:33 in and_it_should_return_json_body │
│ │
│ 30 assert self.response.status_code == 200 │
│ 31 │
│ 32 def and_it_should_return_json_body(self): │
│ ❱ 33 assert json.loads(self.response.body) == {} │
│ 34 │
╰───────────────────────────────────────────────────────────────────────────╯
JSONDecodeError: Expecting value: line 1 column 2 (char 1)
# --seed 19686856-8704-4d7b-8088-6044ba4e8052
# 1 scenario, 0 passed, 1 failed, 0 skipped (0.10s)
Scenarios
*
✗ login as user
✔ given_user_creds
✔ when_user_logins
✔ then_it_should_return_ok_status
✗ and_it_should_return_json_body
╭───────────────────── Traceback (most recent call last) ───────────────────╮
│ /tests/scenarios/login_as_user.py:33 in and_it_should_return_json_body │
│ │
│ 30 assert self.response.status_code == 200 │
│ 31 │
│ 32 def and_it_should_return_json_body(self): │
│ ❱ 33 assert json.loads(self.response.body) == {} │
│ 34 │
│ │
│ /usr/local/lib/python3.12/json/__init__.py:346 in loads │
│ │
│ 343 if (cls is None and object_hook is None and │
│ 344 parse_int is None and parse_float is None and │
│ 345 parse_constant is None and object_pairs_hook is None │
│ ❱ 346 return _default_decoder.decode(s) │
│ 347 if cls is None: │
│ 348 cls = JSONDecoder │
│ 349 if object_hook is not None: │
│ │
│ /usr/local/lib/python3.12/json/decoder.py:337 in decode │
│ │
│ 334 containing a JSON document). │
│ 335 │
│ 336 """ │
│ ❱ 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) │
│ 338 end = _w(s, end).end() │
│ 339 if end != len(s): │
│ 340 raise JSONDecodeError("Extra data", s, end) │
│ │
│ /usr/local/lib/python3.12/json/decoder.py:355 in raw_decode │
│ │
│ 352 try: │
│ 353 obj, end = self.scan_once(s, idx) │
│ 354 except StopIteration as err: │
│ ❱ 355 raise JSONDecodeError("Expecting value", s, err.value) │
│ 356 return obj, end │
│ 357 │
╰───────────────────────────────────────────────────────────────────────────╯
JSONDecodeError: Expecting value: line 1 column 2 (char 1)
# --seed 1094bf78-c18e-4dae-ba73-55c57ac1a105
# 1 scenario, 0 passed, 1 failed, 0 skipped (0.10s)
Traceback Width Control
Set the width of the traceback output with the tb_width
parameter. If not set, the terminal width will be used. The default value is tb_width = 100
.
# vedro.cfg.py
class RichReporter(vedro.plugins.director.rich.RichReporter):
tb_width = 120
Show Scope
The show_scope
parameter (and --show-scope
or -S
argument) provides a snapshot of crucial variables when a test scenario fails. It is now the recommended way to show scope.
$ vedro run -S
For the latest news and updates, subscribe to our Telegram or X (Twitter)