def test_expand_slice(self): p = Placeholder('files')[0:1] self.assertEqual(p.expand(AttrDict(files=[])), []) self.assertEqual(p.expand(AttrDict(files=['foo'])), ['foo']) self.assertEqual(p.expand(AttrDict(files=['foo', 'bar'])), ['foo'])
def test_expand_index(self): p = Placeholder('files')[0] with self.assertRaises(IndexError): p.expand(AttrDict(files=[])) self.assertEqual(p.expand(AttrDict(files=['foo'])), ['foo']) self.assertEqual(p.expand(AttrDict(files=['foo', 'bar'])), ['foo'])