def test_sequence(self): l = util.SequenceView([1, 2, 2]) assert 1 == l[0] assert 3 == len(l) assert 2 in l assert l == [1, 2, 2] assert l == util.SequenceView([1, 2, 2]) assert list(reversed(l)) == [2, 2, 1] assert 1 == l.index(2) assert 2 == l.count(2) assert str(l) == str([1, 2, 2]) # Assert immutability m = l + [3, 4] assert [1, 2, 2, 3, 4] == m assert isinstance(m, util.SequenceView) m = l l += [3, 4] assert m is not l assert [1, 2, 2] == m assert [1, 2, 2, 3, 4] == l assert isinstance(l, util.SequenceView) with pytest.raises(TypeError): l[1] = 3 with pytest.raises(TypeError): l[1:2] = [3] with pytest.raises(TypeError): l *= 3 with pytest.raises(TypeError): del l[:1] with pytest.raises(AttributeError): l.append(3) with pytest.raises(AttributeError): l.clear() with pytest.raises(AttributeError): s = l.copy() with pytest.raises(AttributeError): l.extend([3, 4]) with pytest.raises(AttributeError): l.insert(1, 4) with pytest.raises(AttributeError): l.pop() with pytest.raises(AttributeError): l.remove(2) with pytest.raises(AttributeError): l.reverse()
def test_sequence(self): l = util.SequenceView([1, 2, 2]) self.assertEqual(1, l[0]) self.assertEqual(3, len(l)) self.assertIn(2, l) self.assertEqual(l, [1, 2, 2]) self.assertEqual(l, util.SequenceView([1, 2, 2])) self.assertEqual(list(reversed(l)), [2, 2, 1]) self.assertEqual(1, l.index(2)) self.assertEqual(2, l.count(2)) self.assertEqual(str(l), str([1, 2, 2])) # Assert immutability m = l + [3, 4] self.assertEqual([1, 2, 2, 3, 4], m) self.assertIsInstance(m, util.SequenceView) m = l l += [3, 4] self.assertIsNot(m, l) self.assertEqual([1, 2, 2], m) self.assertEqual([1, 2, 2, 3, 4], l) self.assertIsInstance(l, util.SequenceView) with self.assertRaises(TypeError): l[1] = 3 with self.assertRaises(TypeError): l[1:2] = [3] with self.assertRaises(TypeError): l *= 3 with self.assertRaises(TypeError): del l[:1] with self.assertRaises(AttributeError): l.append(3) with self.assertRaises(AttributeError): l.clear() with self.assertRaises(AttributeError): s = l.copy() with self.assertRaises(AttributeError): l.extend([3, 4]) with self.assertRaises(AttributeError): l.insert(1, 4) with self.assertRaises(AttributeError): l.pop() with self.assertRaises(AttributeError): l.remove(2) with self.assertRaises(AttributeError): l.reverse()
def environs(self): '''The programming environments associated with this system partition. :type: :class:`List[ProgEnvironment]` ''' return utility.SequenceView(self._environs)
def modules_detailed(self): '''A view of the modules associated with this environment in a detailed format. Each module is represented as a dictionary with the following attributes: - ``name``: the name of the module. - ``collection``: :class:`True` if the module name refers to a module collection. :type: :class:`List[Dict[str, object]]` .. versionadded:: 3.3 ''' return util.SequenceView(self._modules)
def partitions(self): '''The system partitions associated with this system. :type: :class:`List[SystemPartition]` ''' return utility.SequenceView(self._partitions)
def access(self): '''The scheduler options for accessing this system partition. :type: :class:`List[str]` ''' return utility.SequenceView(self._access)
def modules(self): """The modules associated with this environment. :type: :class:`list` of :class:`str` """ return util.SequenceView(self._modules)
def environs(self): return utility.SequenceView(self._environs)
def access(self): return utility.SequenceView(self._access)
def partitions(self): '''All the system partitions associated with this system.''' return utility.SequenceView(self._partitions)
def modules(self): '''The modules associated with this environment. :type: :class:`List[str]` ''' return util.SequenceView(self._modules)
def user_deps(self): return util.SequenceView(self._userdeps)