
leonW
Python Testing with pytest, Second Edition: File not Found Error (page 43)
I ran this command after installing the sample application:
$ cards add do something --owner Brian
And got a file not found error:
FileNotFoundError: [Errno 2] No such file or directory: ‘/Users/tslcw/cards_db/.cards_db.json’
perhaps this is because I am using a folder in drop box as my work directory? Also, it would be nice to have an option to create the cards db in the cards_proj folder or the cards directory in the venv directory.
Marked As Solved

leonW
This problem can be fixed by modifying the init method in db.py so that tiny.db creates directories:
def init(self, db_path, db_file_prefix):
self._db = tinydb.TinyDB(db_path / f"{db_file_prefix}.json", create_dirs=True)
It is dunder init, but the forum software seems to be removing the dunders.
Also Liked

leonW
I am using Mac OS Big Sur and bash v 5. Switching to a local dir made no difference. But see my reply—adding “create_dirs=True” to statement in init method in db.py fixed my issue.

brian-m-ops
I had the same issue using Linux(PopOS).
Workaround that worked for me was to just manually create the cards_db directory and then a hidden file named name .cards_db.json inside of that cards_db directory.
/home/user/cards_db/.cards_db.json

kaphola
I preferred this solution instead creating folder manually.
-
Change code as you suggested
-
Reinstalled cards
Its working now
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /java
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim