leonW

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

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

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

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

kaphola

I preferred this solution instead creating folder manually.

  • Change code as you suggested

  • Reinstalled cards

Its working now :slightly_smiling_face:

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
leonW
I ran this command after installing the sample application: $ cards add do something --owner Brian And got a file not found error: Fil...
New
jgchristopher
“The ProductLive.Index template calls a helper function, live_component/3, that in turn calls on the modal component. ” Excerpt From: Br...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New

Other popular topics Top

DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New

Sub Categories: