diff --git a/svn/common.py b/svn/common.py index c48d25a..0034e1c 100644 --- a/svn/common.py +++ b/svn/common.py @@ -154,6 +154,9 @@ def properties(self, rel_path=None): # query the proper list of this path root = xml.etree.ElementTree.fromstring(result) target_elem = root.find('target') + if not target_elem: + return {} + property_names = [p.attrib["name"] for p in target_elem.findall('property')] diff --git a/tests/test_common.py b/tests/test_common.py index 51fcabe..e0a5f0c 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -14,6 +14,23 @@ def __init__(self, *args, **kwargs): self.maxDiff = None super(TestCommonClient, self).__init__(*args, **kwargs) + def test_properties(self): + with svn.test_support.temp_repo(): + with svn.test_support.temp_checkout() as (working_path, lc): + svn.test_support.populate_bigger_file_changes1() + + self.assertEqual(0, len(lc.properties('new_file'))) + self.assertEqual(0, len(lc.properties('committed_unchanged'))) + + binary_file = 'binary.dat' + with open(os.path.join(working_path, binary_file), 'wb') as f: + f.write((10).to_bytes(10, 'big')) + lc.add(binary_file) # file must be added to have props detected + binary_props = lc.properties(binary_file) + self.assertEqual(1, len(binary_props)) + self.assertIsNotNone(binary_props['svn:mime-type']) + self.assertEqual('application/octet-stream', binary_props['svn:mime-type']) + def test_update(self): with svn.test_support.temp_repo(): with svn.test_support.temp_checkout() as (_, lc):