<commit_before># Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2015 Stratosphere Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain 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.
# vim: tabstop=4 shiftwidth=4 softtabstop=4

try:
    import mock  # Python 2
except ImportError:
    from unittest import mock  # Python 3

import json
import os
import sys
import warnings
import unittest
import logging
import random

from ryu.base import app_manager  # To suppress cyclic import
from ryu.controller import controller
from ryu.controller import handler
from ryu.ofproto import ofproto_v1_3_parser
from ryu.ofproto import ofproto_v1_2_parser
from ryu.ofproto import ofproto_v1_0_parser


LOG = logging.getLogger('test_controller')


class Test_Datapath(unittest.TestCase):
    """
    Test cases for controller.Datapath
    """
<commit_msg>test_controller: Test cases for _split_addr()<commit_after># Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2015 Stratosphere Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain 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.
# vim: tabstop=4 shiftwidth=4 softtabstop=4

try:
    import mock  # Python 2
except ImportError:
    from unittest import mock  # Python 3

import json
import os
import sys
import warnings
import logging
import random
import unittest

from nose.tools import eq_, raises

from ryu.base import app_manager  # To suppress cyclic import
from ryu.controller import controller
from ryu.controller import handler
from ryu.ofproto import ofproto_v1_3_parser
from ryu.ofproto import ofproto_v1_2_parser
from ryu.ofproto import ofproto_v1_0_parser


LOG = logging.getLogger('test_controller')


class TestUtils(unittest.TestCase):
    """
    Test cases for utilities defined in controller module.
    """

    def test_split_addr_with_ipv4(self):
        addr, port = controller._split_addr('127.0.0.1:6653')
        eq_('127.0.0.1', addr)
        eq_(6653, port)

    def test_split_addr_with_ipv6(self):
        addr, port = controller._split_addr('[::1]:6653')
        eq_('::1', addr)
        eq_(6653, port)

    @raises(ValueError)
    def test_split_addr_with_invalid_addr(self):
        controller._split_addr('127.0.0.1')

    @raises(ValueError)
    def test_split_addr_with_invalid_ipv4_addr(self):
        controller._split_addr('xxx.xxx.xxx.xxx:6653')

    @raises(ValueError)
    def test_split_addr_with_invalid_ipv6_addr(self):
        controller._split_addr('[::xxxx]:6653')

    @raises(ValueError)
    def test_split_addr_with_non_bracketed_ipv6_addr(self):
        controller._split_addr('::1:6653')


class Test_Datapath(unittest.TestCase):
    """
    Test cases for controller.Datapath
    """

{'fraction_non_alphanumeric': 0.07880285557386052, 'fraction_numerical': 0.027457440966501923, 'mean_word_length': 4.264450867052023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1074917', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1079, 'n_words': 371}