geneagrapher icon indicating copy to clipboard operation
geneagrapher copied to clipboard

Don't assume that database files have .db extension in tests

Open d-torrance opened this issue 3 years ago • 0 comments

I'm getting the following test error:

ERROR: test_init2 (tests.geneagrapher.test_cache_grabber.TestCacheGrabberMethods)
Test constructor with non-default filename.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/profzoom/src/geneagrapher/geneagrapher/tests/geneagrapher/test_cache_grabber.py", line 42, in test_init2
    os.remove("mycachename.db")
FileNotFoundError: [Errno 2] No such file or directory: 'mycachename.db'

This is because the file that was created by CacheGrabber's initialization method doesn't have the .db extension:

$ ls mycachename*
mycachename

According to the shelve docs, there's no guarantee as to the presence of an extension (or even the number of files created!):

The filename specified is the base filename for the underlying database. As a side-effect, an extension may be added to the filename and more than one file may be created.

d-torrance avatar Aug 21 '21 12:08 d-torrance