Example #1
0
    def test_getatttr(self):
        new = ResultTuple._new_type([None, "foo", None, "bar"])
        inst = new([1, 2, 3, "a"])

        self.assertTrue(hasattr(inst, "foo"))
        self.assertEqual(inst.foo, inst[1])
        self.assertRaises(AttributeError, getattr, inst, "nope")
Example #2
0
    def test_getatttr(self):
        new = ResultTuple._new_type([None, "foo", None, "bar"])
        inst = new([1, 2, 3, "a"])

        self.assertTrue(hasattr(inst, "foo"))
        self.assertEqual(inst.foo, inst[1])
        self.assertRaises(AttributeError, getattr, inst, "nope")
Example #3
0
    def test_pickle(self):
        new = ResultTuple._new_type([None, "foo", None, "bar"])
        inst = new([1, 2, 3, "a"])

        inst2 = pickle.loads(pickle.dumps(inst))
        self.assertEqual(inst2, inst)
        self.assertTrue(isinstance(inst2, tuple))
        self.assertFalse(isinstance(inst2, new))
Example #4
0
    def test_pickle(self):
        new = ResultTuple._new_type([None, "foo", None, "bar"])
        inst = new([1, 2, 3, "a"])

        inst2 = pickle.loads(pickle.dumps(inst))
        self.assertEqual(inst2, inst)
        self.assertTrue(isinstance(inst2, tuple))
        self.assertFalse(isinstance(inst2, new))
Example #5
0
 def test_repr_dir_empty(self):
     new = ResultTuple._new_type([])
     inst = new()
     self.assertEqual(repr(inst), "()")
     dir(inst)
Example #6
0
    def test_repr_dir(self):
        new = ResultTuple._new_type([None, "foo", None, "bar"])
        inst = new([1, 2, 3, "a"])

        self.assertEqual(repr(inst), "(1, foo=2, 3, bar='a')")
        self.assertTrue("foo" in dir(inst))
Example #7
0
 def test_create(self):
     new = ResultTuple._new_type([None, "foo", None, "bar"])
     self.assertTrue(issubclass(new, ResultTuple))
Example #8
0
 def test_repr_dir_empty(self):
     new = ResultTuple._new_type([])
     inst = new()
     self.assertEqual(repr(inst), "()")
     dir(inst)
Example #9
0
    def test_repr_dir(self):
        new = ResultTuple._new_type([None, "foo", None, "bar"])
        inst = new([1, 2, 3, "a"])

        self.assertEqual(repr(inst), "(1, foo=2, 3, bar='a')")
        self.assertTrue("foo" in dir(inst))
Example #10
0
 def test_create(self):
     new = ResultTuple._new_type([None, "foo", None, "bar"])
     self.assertTrue(issubclass(new, ResultTuple))