Пример #1
0
    def test_resetting_id_warns_on_set_id(self):
        """
        Because the ResourceIdentifier class hashes on the id attribute, it
        should warn if it is being changed. This tests the case were an id is
        manually specified.
        """
        rid = ResourceIdentifier('a very unique string indeed')
        with WarningsCapture() as w:
            warnings.simplefilter('default')
            rid.id = 'Another string that will mess up the hash. Bad.'

        self.assertEqual(len(w), 1)
        self.assertIn('overwritting the id attribute', str(w[0].message))
Пример #2
0
    def test_resetting_id_warns_on_default_id(self):
        """
        Because the ResourceIdentifier class hashes on the id attribute, it
        should warn if it is being changed. This tests the case were an id is
        not specified and the default uuid is used.
        """
        rid = ResourceIdentifier()
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('default')
            rid.id = 'Another string that will mess up the hash. Bad.'

        self.assertEqual(len(w), 1)
        self.assertIn('overwritting the id attribute', str(w[0]))
Пример #3
0
    def test_resetting_id_warns_on_set_id(self):
        """
        Because the ResourceIdentifier class hashes on the id attribute, it
        should warn if it is being changed. This tests the case were an id is
        manually specified.
        """
        rid = ResourceIdentifier('a very unique string indeed')
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('default')
            rid.id = 'Another string that will mess up the hash. Bad.'

        assert len(w) == 1
        assert 'overwritting the id attribute' in str(w[0].message)
Пример #4
0
    def test_resetting_id_warns_on_set_id(self):
        """
        Because the ResourceIdentifier class hashes on the id attribute, it
        should warn if it is being changed. This tests the case were an id is
        manually specified.
        """
        rid = ResourceIdentifier('a very unique string indeed')
        with WarningsCapture() as w:
            warnings.simplefilter('default')
            rid.id = 'Another string that will mess up the hash. Bad.'

        self.assertEqual(len(w), 1)
        self.assertIn('overwritting the id attribute', str(w[0].message))