Thomas Waldmann 9 лет назад
Родитель
Сommit
46362a1962
1 измененных файлов с 13 добавлено и 0 удалено
  1. 13 0
      borg/testsuite/item.py

+ 13 - 0
borg/testsuite/item.py

@@ -40,11 +40,24 @@ def test_item_from_dict():
     assert item.mode == 0o666
     assert 'path' in item
 
+    # does not matter whether we get str or bytes keys
     item = Item({'path': b'/a/b/c', 'mode': 0o666})
     assert item.path == '/a/b/c'
     assert item.mode == 0o666
     assert 'mode' in item
 
+    # invalid - no dict
+    with pytest.raises(TypeError):
+        Item(42)
+
+    # invalid - no bytes/str key
+    with pytest.raises(TypeError):
+        Item({42: 23})
+
+    # invalid - unknown key
+    with pytest.raises(ValueError):
+        Item({'foobar': 'baz'})
+
 
 def test_item_from_kw():
     item = Item(path=b'/a/b/c', mode=0o666)