RhetTbull / osxmetadata

Python package to read and write various MacOS extended attribute metadata such as tags/keywords and Finder comments from files. Includes CLI tool for reading/writing metadata.
MIT License
125 stars 4 forks source link

kMDItemAuthors tests fail on Big Sur, Monterey but not on Catalina #68

Open RhetTbull opened 2 years ago

RhetTbull commented 2 years ago
    I'll add a note to the docs about temporary files.  I got the test suite running last night in GitHub actions (via a BigSur VM, the latest available in GitHub).  Interestingly the same three tests fail with the same result.  Something about `kMDItemAuthors` isn't right for macOS > Catalina.   I'll open a separate issue for this. 
tests/test_cli.py:517: AssertionError
=========================== short test summary info ============================
FAILED tests/test_cli.py::test_cli_remove - AssertionError: assert ['John Doe...
FAILED tests/test_cli.py::test_cli_backup_restore - AssertionError: assert no...
FAILED tests/test_cli.py::test_cli_order - AssertionError: assert ['John Doe'...
=================== 3 failed, 551 passed, 3 skipped in 8.14s ===================

Originally posted by @RhetTbull in https://github.com/RhetTbull/osxmetadata/issues/61#issuecomment-1272576053

RhetTbull commented 2 years ago

I am able to replicate this on a machine with Big Sur. The CLI tests manipulating kMDItemAuthors fail every time BUT when I open a python REPL and shell and replicate the tests manually, line by line, everything works as expected. I believe this and the finder comment failures have something to do with the pytest environment but I can't figure out the issue.

>>> from osxmetadata import *
>>> md = OSXMetaData("test_file.txt")
>>> md.tags = [Tag("test",0)]
>>> md.tags
[Tag(name='test', color=0)]
>>> md.authors = ["John Doe", "Jane Doe"]
>>> md.wherefroms =["http://www.apple.com"]
>>> import datetime
>>> md.downloadeddate = [datetime.datetime(2019,1,1)]
>>> md.findercomment = "Hello World"
python -m osxmetadata test_file.txt --get comment --set authors "John
 Smith" --restore --set title "Test Title" --clear title --append tags test2 --set comment foo --remove authors "Jane Do
e" --append authors "Jane Smith" --mirror comment findercomment
comment                   kMDItemComment                    = Hello World
Python 3.10.4 (main, Apr 26 2022, 19:43:24) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from osxmetadata import *
>>> from osxmetadata import *
>>> md = OSXMetaData("test_file.txt")
>>> md.authors
['John Smith', 'Jane Smith']