Exemplo n.º 1
0
 def test_equality(self):
     """
     A L{NamedConstant} instance compares equal to itself.
     """
     name = NamedConstant()
     name._realize(self.container, "bar", None)
     self.assertTrue(name == name)
     self.assertFalse(name != name)
Exemplo n.º 2
0
 def test_name(self):
     """
     The C{name} attribute of a L{NamedConstant} refers to the value passed
     for the C{name} parameter to C{_realize}.
     """
     name = NamedConstant()
     name._realize(self.container, "bar", None)
     self.assertEqual("bar", name.name)
Exemplo n.º 3
0
 def test_representation(self):
     """
     The string representation of an instance of L{NamedConstant} includes
     the container the instances belongs to as well as the instance's name.
     """
     name = NamedConstant()
     name._realize(self.container, "bar", None)
     self.assertEqual("<foo=bar>", repr(name))
Exemplo n.º 4
0
 def test_equality(self):
     """
     A L{NamedConstant} instance compares equal to itself.
     """
     name = NamedConstant()
     name._realize(self.container, "bar", None)
     self.assertTrue(name == name)
     self.assertFalse(name != name)
Exemplo n.º 5
0
 def test_representation(self):
     """
     The string representation of an instance of L{NamedConstant} includes
     the container the instances belongs to as well as the instance's name.
     """
     name = NamedConstant()
     name._realize(self.container, "bar", None)
     self.assertEqual("<foo=bar>", repr(name))
Exemplo n.º 6
0
 def test_name(self):
     """
     The C{name} attribute of a L{NamedConstant} refers to the value passed
     for the C{name} parameter to C{_realize}.
     """
     name = NamedConstant()
     name._realize(self.container, "bar", None)
     self.assertEqual("bar", name.name)
Exemplo n.º 7
0
 def test_hash(self):
     """
     Because two different L{NamedConstant} instances do not compare as
     equal to each other, they also have different hashes to avoid
     collisions when added to a C{dict} or C{set}.
     """
     first = NamedConstant()
     first._realize(self.container, "bar", None)
     second = NamedConstant()
     second._realize(self.container, "bar", None)
     self.assertNotEqual(hash(first), hash(second))
Exemplo n.º 8
0
 def test_nonequality(self):
     """
     Two different L{NamedConstant} instances do not compare equal to each
     other.
     """
     first = NamedConstant()
     first._realize(self.container, "bar", None)
     second = NamedConstant()
     second._realize(self.container, "bar", None)
     self.assertFalse(first == second)
     self.assertTrue(first != second)
Exemplo n.º 9
0
 def test_hash(self):
     """
     Because two different L{NamedConstant} instances do not compare as
     equal to each other, they also have different hashes to avoid
     collisions when added to a C{dict} or C{set}.
     """
     first = NamedConstant()
     first._realize(self.container, "bar", None)
     second = NamedConstant()
     second._realize(self.container, "bar", None)
     self.assertNotEqual(hash(first), hash(second))
Exemplo n.º 10
0
 def test_nonequality(self):
     """
     Two different L{NamedConstant} instances do not compare equal to each
     other.
     """
     first = NamedConstant()
     first._realize(self.container, "bar", None)
     second = NamedConstant()
     second._realize(self.container, "bar", None)
     self.assertFalse(first == second)
     self.assertTrue(first != second)