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:

Popular Prag Prog 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
johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
New
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
Mmm
Hi, build fails on: bracket-lib = “~0.8.1” when running on Mac Mini M1 Rust version 1.5.0: Compiling winit v0.22.2 error[E0308]: mi...
New
HarryDeveloper
Hi @venkats, It has been mentioned in the description of ‘Supervisory Job’ title that 2 things as mentioned below result in the same eff...
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1017 16885 373
New
PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
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
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New

Latest in PragProg

View all threads ❯