mirror of
https://github.com/jbranchaud/til
synced 2026-07-02 15:49:44 +00:00
Compare commits
3 Commits
1a4589f8f7
...
906253b7dc
| Author | SHA1 | Date | |
|---|---|---|---|
| 906253b7dc | |||
| b4920c0397 | |||
| 119cc15c9a |
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
||||
|
||||
_1768 TILs and counting..._
|
||||
_1770 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
|
||||
@@ -1061,6 +1061,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Look Inside Pytest tmp_path](python/look-inside-pytest-tmp-path.md)
|
||||
- [Override The Boolean Context Of A Class](python/override-the-boolean-context-of-a-class.md)
|
||||
- [Parse Relative Time To datetime Object](python/parse-relative-time-to-datetime-object.md)
|
||||
- [Skip Specific Pytest Test Cases](python/skip-specific-pytest-test-cases.md)
|
||||
- [Start The Debugger When A Test Errors](python/start-the-debugger-when-a-test-errors.md)
|
||||
- [Store And Access Immutable Data In A Tuple](python/store-and-access-immutable-data-in-a-tuple.md)
|
||||
- [Test A Function With Pytest](python/test-a-function-with-pytest.md)
|
||||
@@ -2089,6 +2090,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Add To The Path Via Path Array](zsh/add-to-the-path-via-path-array.md)
|
||||
- [Create And Jump Into A Directory](zsh/create-and-jump-into-a-directory.md)
|
||||
- [Link A Scalar To An Array](zsh/link-a-scalar-to-an-array.md)
|
||||
- [List Available Zle Keybindings](zsh/list-available-zle-keybindings.md)
|
||||
- [Use A Space To Exclude Command From History](zsh/use-a-space-to-exclude-command-from-history.md)
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# Skip Specific Pytest Test Cases
|
||||
|
||||
While using a failing test case to build a small new feature for
|
||||
[`py-vmt`](https://github.com/jbranchaud/py-vmt), I realized I needed to do some
|
||||
refactoring first. It wasn't significant enough to warrant stashing my current
|
||||
changes and switching to a different branch, so I kept all the changes around. I
|
||||
did find the initial failing test distracting from the refactoring I was trying
|
||||
to do. To temporarily shelve that failure, I can use a Pytest decorator to mark
|
||||
it as _skipped_.
|
||||
|
||||
```python
|
||||
@pytest.mark.skip(reason="not yet implemented")
|
||||
def test_log_recent_activity():
|
||||
runner = CliRunner()
|
||||
|
||||
# set up the data dir file with some existing session entries
|
||||
initial_datetime = datetime.datetime(
|
||||
2026, 3, 14, 15, 5, 11, 0, datetime.timezone.utc
|
||||
)
|
||||
with freeze_time(initial_datetime) as frozen_datetime:
|
||||
# ...
|
||||
```
|
||||
|
||||
The [`@pytest.mark.skip` decorator](https://docs.pytest.org/en/stable/how-to/skipping.html#skipping-test-functions)
|
||||
tells the Pytest runner to skip of that specific test case instead of executing
|
||||
it. In the test runner output, I'll see an `s` rather than a `.` or `F` and the
|
||||
summary will include it in a count of skipped tests:
|
||||
|
||||
```
|
||||
=========================== 3 failed, 4 passed, 1 skipped in 0.09s ===========================
|
||||
```
|
||||
|
||||
Another way to think about this is to mark this test case as _expected to fail_
|
||||
with `@pytest.mark.xfail`. That will display as an `x` and show up in the summary as:
|
||||
|
||||
```
|
||||
=========================== 3 failed, 4 passed, 1 xfailed in 0.11s ===========================
|
||||
```
|
||||
@@ -8,8 +8,7 @@ however, I learned about a couple more reading through [Shell Tricks That
|
||||
Actually Make Life Easier (And Save Your
|
||||
Sanity)](https://blog.hofstede.it/shell-tricks-that-actually-make-life-easier-and-save-your-sanity/).
|
||||
|
||||
These are [Readline
|
||||
commands](https://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html)
|
||||
These are [Readline commands](https://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html)
|
||||
(or keybindings) which means they are supported by anything that uses Readline
|
||||
under the hood. So while you might be using these to great effect in `bash` and
|
||||
`zsh`, you should look for other places they are available.
|
||||
@@ -17,11 +16,15 @@ under the hood. So while you might be using these to great effect in `bash` and
|
||||
A non-exhaustive list includes:
|
||||
|
||||
- Ruby's `irb`
|
||||
- `python`
|
||||
- Python's `python`
|
||||
- Node.js' `node`
|
||||
- PostgreSQL's `psql`
|
||||
- Claude Code
|
||||
|
||||
And many more similar REPLs and command line tools.
|
||||
|
||||
Try these keybindings out in one of your favorites and when you're done hit
|
||||
`ctrl-c` to exit out of it.
|
||||
|
||||
PS. subsets of these keybindings are sometimes supported in unexpected places
|
||||
like the Chrome URL bar.
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# List Available Zle Keybindings
|
||||
|
||||
Unlike `bash` which uses `readline`, `zsh` has its own implementation of a line
|
||||
editing library -- `zle`. A lot of the core bindings between the two are the
|
||||
same, e.g. `Ctrl-a` and `Ctrl-e` to go the beginning and end of the command line
|
||||
prompt, respectively.
|
||||
|
||||
All available `zle` keybindings can be listed out by running `bindkey` without
|
||||
any arguments.
|
||||
|
||||
The best way to check out an unaltered version of this list is by starting a
|
||||
fresh `zsh` process with no RCS files loaded in. The `-f` flag does that. Note
|
||||
though that when `zsh` is starting fresh, it has to decide whether to start in
|
||||
_Emacs_ mode or _Vi_ mode. If it sees that your default editor is something like
|
||||
`vi`, `vim` or `nvim`, then it will start you in _Vi_ mode.
|
||||
|
||||
Starting in _Vi_ mode can be confusing because none of the standard _Emacs_
|
||||
keybindings like `Ctrl-a` and `Ctrl-e` are available in that context. So first
|
||||
ensure you're in _Emacs_ mode by running:
|
||||
|
||||
```sh
|
||||
❯ zsh -f
|
||||
lastword% bindkey -e
|
||||
```
|
||||
|
||||
Now you can list out all the keybindings:
|
||||
|
||||
```sh
|
||||
lastword% bindkey
|
||||
"^@" set-mark-command
|
||||
"^A" beginning-of-line
|
||||
"^B" backward-char
|
||||
"^D" delete-char-or-list
|
||||
"^E" end-of-line
|
||||
"^F" forward-char
|
||||
"^G" send-break
|
||||
"^H" backward-delete-char
|
||||
"^I" expand-or-complete
|
||||
"^J" accept-line
|
||||
"^K" kill-line
|
||||
...
|
||||
```
|
||||
|
||||
See `man zshzle` for more details on `zle` and `bindkey`.
|
||||
Reference in New Issue
Block a user