Esempio n. 1
0
 def test_sentinel_copy(self):
     singleton = constants.Sentinel()
     self.assertEqual(copy.deepcopy(singleton), copy.copy(singleton))
Esempio n. 2
0
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import abc

from neutron_lib._i18n import _
from neutron_lib import constants

_UNSET = constants.Sentinel()


def is_extension_supported(plugin, alias):
    """Validate that the extension is supported.

    :param plugin: The plugin class.
    :param alias: The alias to check.
    :returns: True if the alias is supported else False.
    """
    return alias in getattr(plugin, "supported_extension_aliases", [])


class ExtensionDescriptor(object, metaclass=abc.ABCMeta):
    """Base class that defines the contract for extensions."""
    @abc.abstractmethod
Esempio n. 3
0
 def test_sentinel_constant(self):
     foo = constants.Sentinel()
     bar = copy.deepcopy(foo)
     self.assertEqual(id(foo), id(bar))