def test_subscripts(self): a = QN('a') b = QN('b') a_sub_b = QN(a, subscript=b) self.assertEqual(a_sub_b.qn, (a, b)) self.assertEqual(str(a_sub_b), 'a[b]') self.assertEqual(a_sub_b.ssf(), 'a_sub_b') self.assertEqual(a_sub_b.ast().value.id, 'a') self.assertEqual(a_sub_b.ast().slice.value.id, 'b') self.assertTrue(a_sub_b.is_composite()) self.assertTrue(a_sub_b.has_subscript()) self.assertEqual(a_sub_b.parent.qn, ('a',)) c = QN('c') b_sub_c = QN(b, subscript=c) a_sub_b_sub_c = QN(a, subscript=b_sub_c) self.assertEqual(a_sub_b_sub_c.qn, (a, b_sub_c)) self.assertTrue(a_sub_b.is_composite()) self.assertTrue(a_sub_b_sub_c.is_composite()) self.assertTrue(a_sub_b.has_subscript()) self.assertTrue(a_sub_b_sub_c.has_subscript()) self.assertEqual(b_sub_c.qn, (b, c)) self.assertEqual(str(a_sub_b_sub_c), 'a[b[c]]') self.assertEqual(a_sub_b_sub_c.ssf(), 'a_sub_b_sub_c') self.assertEqual(a_sub_b_sub_c.ast().value.id, 'a') self.assertEqual(a_sub_b_sub_c.ast().slice.value.value.id, 'b') self.assertEqual(a_sub_b_sub_c.ast().slice.value.slice.value.id, 'c') self.assertEqual(b_sub_c.ast().slice.value.id, 'c') self.assertEqual(a_sub_b_sub_c.parent.qn, ('a',)) with self.assertRaises(ValueError): QN('a', 'b')
def test_subscripts(self): a = QN('a') b = QN('b') a_sub_b = QN(a, subscript=b) self.assertEqual(a_sub_b.qn, (a, b)) self.assertEqual(str(a_sub_b), 'a[b]') self.assertEqual(a_sub_b.ssf(), 'a_sub_b') self.assertEqual(a_sub_b.ast().value.id, 'a') self.assertEqual(a_sub_b.ast().slice.value.id, 'b') self.assertTrue(a_sub_b.is_composite()) self.assertTrue(a_sub_b.has_subscript()) self.assertEqual(a_sub_b.parent.qn, ('a', )) c = QN('c') b_sub_c = QN(b, subscript=c) a_sub_b_sub_c = QN(a, subscript=b_sub_c) self.assertEqual(a_sub_b_sub_c.qn, (a, b_sub_c)) self.assertTrue(a_sub_b.is_composite()) self.assertTrue(a_sub_b_sub_c.is_composite()) self.assertTrue(a_sub_b.has_subscript()) self.assertTrue(a_sub_b_sub_c.has_subscript()) self.assertEqual(b_sub_c.qn, (b, c)) self.assertEqual(str(a_sub_b_sub_c), 'a[b[c]]') self.assertEqual(a_sub_b_sub_c.ssf(), 'a_sub_b_sub_c') self.assertEqual(a_sub_b_sub_c.ast().value.id, 'a') self.assertEqual(a_sub_b_sub_c.ast().slice.value.value.id, 'b') self.assertEqual(a_sub_b_sub_c.ast().slice.value.slice.value.id, 'c') self.assertEqual(b_sub_c.ast().slice.value.id, 'c') self.assertEqual(a_sub_b_sub_c.parent.qn, ('a', )) with self.assertRaises(ValueError): QN('a', 'b')
def test_basic(self): a = QN('a') self.assertEqual(a.qn, ('a',)) self.assertEqual(str(a), 'a') self.assertEqual(a.ssf(), 'a') self.assertEqual(a.ast().id, 'a') self.assertFalse(a.is_composite()) with self.assertRaises(ValueError): _ = a.parent a_b = QN(a, attr='b') self.assertEqual(a_b.qn, (a, 'b')) self.assertEqual(str(a_b), 'a.b') self.assertEqual(a_b.ssf(), 'a_b') self.assertEqual(a_b.ast().value.id, 'a') self.assertEqual(a_b.ast().attr, 'b') self.assertTrue(a_b.is_composite()) self.assertEqual(a_b.parent.qn, ('a',))
def test_basic(self): a = QN('a') self.assertEqual(a.qn, ('a', )) self.assertEqual(str(a), 'a') self.assertEqual(a.ssf(), 'a') self.assertEqual(a.ast().id, 'a') self.assertFalse(a.is_composite()) with self.assertRaises(ValueError): _ = a.parent a_b = QN(a, attr='b') self.assertEqual(a_b.qn, (a, 'b')) self.assertEqual(str(a_b), 'a.b') self.assertEqual(a_b.ssf(), 'a_b') self.assertEqual(a_b.ast().value.id, 'a') self.assertEqual(a_b.ast().attr, 'b') self.assertTrue(a_b.is_composite()) self.assertEqual(a_b.parent.qn, ('a', ))