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
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
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
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
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
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New

Latest in PragProg

View all threads ❯