Skip to content

Commit

Permalink
Fix "_" no longer allowed in xattr keys (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant committed May 5, 2023
1 parent f2425f0 commit 8463c23
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions s3fs/tests/test_s3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def test_checksum(s3):
s3.checksum(path1, refresh=True)


test_xattr_sample_metadata = {"test_xattr": "1"}
test_xattr_sample_metadata = {"testxattr": "1"}


def test_xattr(s3):
Expand All @@ -389,7 +389,7 @@ def test_xattr(s3):
},
}

sync(
resp = sync(
s3.loop,
s3.s3.put_object,
Bucket=bucket,
Expand All @@ -406,18 +406,16 @@ def test_xattr(s3):
in sync(s3.loop, s3.s3.get_object_acl, Bucket=bucket, Key=key)["Grants"]
)

assert (
s3.getxattr(filename, "test_xattr") == test_xattr_sample_metadata["test_xattr"]
)
assert s3.metadata(filename) == {"test-xattr": "1"} # note _ became -
assert s3.getxattr(filename, "testxattr") == test_xattr_sample_metadata["testxattr"]
assert s3.metadata(filename) == {"testxattr": "1"} # note _ became -

s3file = s3.open(filename)
assert s3file.getxattr("test_xattr") == test_xattr_sample_metadata["test_xattr"]
assert s3file.metadata() == {"test-xattr": "1"} # note _ became -
assert s3file.getxattr("testxattr") == test_xattr_sample_metadata["testxattr"]
assert s3file.metadata() == {"testxattr": "1"} # note _ became -

s3file.setxattr(test_xattr="2")
assert s3file.getxattr("test_xattr") == "2"
s3file.setxattr(**{"test_xattr": None})
s3file.setxattr(testxattr="2")
assert s3file.getxattr("testxattr") == "2"
s3file.setxattr(**{"testxattr": None})
assert s3file.metadata() == {}
assert s3.cat(filename) == body

Expand Down

0 comments on commit 8463c23

Please sign in to comment.