Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'idna' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
def test_check_initial_combiner(self):
m = u'\u0300'
a = u'\u0061'
self.assertTrue(idna.check_initial_combiner(a))
self.assertTrue(idna.check_initial_combiner(a + m))
self.assertRaises(idna.IDNAError, idna.check_initial_combiner, m + a)
# 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.
#
from __future__ import print_function
import idna.core
import sys
print(idna.core, "idna.idnadata" in sys.modules)
def test_encode(self):
self.assertEqual(idna.encode('xn--zckzah.xn--zckzah'), b'xn--zckzah.xn--zckzah')
self.assertEqual(idna.encode(u'\u30c6\u30b9\u30c8.xn--zckzah'), b'xn--zckzah.xn--zckzah')
self.assertEqual(idna.encode(u'\u30c6\u30b9\u30c8.\u30c6\u30b9\u30c8'), b'xn--zckzah.xn--zckzah')
self.assertEqual(idna.encode('abc.abc'), b'abc.abc')
self.assertEqual(idna.encode('xn--zckzah.abc'), b'xn--zckzah.abc')
self.assertEqual(idna.encode(u'\u30c6\u30b9\u30c8.abc'), b'xn--zckzah.abc')
self.assertEqual(idna.encode(u'\u0521\u0525\u0523-\u0523\u0523-----\u0521\u0523\u0523\u0523.aa'),
b'xn---------90gglbagaar.aa')
self.assertRaises(idna.IDNAError, idna.encode,
u'\u0521\u0524\u0523-\u0523\u0523-----\u0521\u0523\u0523\u0523.aa', uts46=False)
self.assertEqual(idna.encode('a'*63), b'a'*63)
self.assertRaises(idna.IDNAError, idna.encode, 'a'*64)
self.assertRaises(idna.core.InvalidCodepoint, idna.encode, '*')
def _test_containment(self, ints, disjoint_ints):
ranges = intranges_from_list(ints)
for int_ in ints:
assert intranges_contain(int_, ranges)
for int_ in disjoint_ints:
assert not intranges_contain(int_, ranges)
def _test_containment(self, ints, disjoint_ints):
ranges = intranges_from_list(ints)
for int_ in ints:
assert intranges_contain(int_, ranges)
for int_ in disjoint_ints:
assert not intranges_contain(int_, ranges)
def testIDNTLDALabels(self):
for (ulabel, alabel) in self.tld_strings:
self.assertEqual(alabel, idna.alabel(ulabel))
def test_skips(self):
self.assertEqual(
intranges_from_list([0, 2, 4, 6, 9, 10, 11, 13, 15,]),
(
_encode_range(0, 1),
_encode_range(2, 3),
_encode_range(4, 5),
_encode_range(6, 7),
_encode_range(9, 12),
_encode_range(13, 14),
_encode_range(15, 16),
)
def test_skips(self):
self.assertEqual(
intranges_from_list([0, 2, 4, 6, 9, 10, 11, 13, 15,]),
(
_encode_range(0, 1),
_encode_range(2, 3),
_encode_range(4, 5),
_encode_range(6, 7),
_encode_range(9, 12),
_encode_range(13, 14),
_encode_range(15, 16),
)
def test_skips(self):
self.assertEqual(
intranges_from_list([0, 2, 4, 6, 9, 10, 11, 13, 15,]),
(
_encode_range(0, 1),
_encode_range(2, 3),
_encode_range(4, 5),
_encode_range(6, 7),
_encode_range(9, 12),
_encode_range(13, 14),
_encode_range(15, 16),
)
def test_skips(self):
self.assertEqual(
intranges_from_list([0, 2, 4, 6, 9, 10, 11, 13, 15,]),
(
_encode_range(0, 1),
_encode_range(2, 3),
_encode_range(4, 5),
_encode_range(6, 7),
_encode_range(9, 12),
_encode_range(13, 14),
_encode_range(15, 16),
)