How to use _test_string method in tempest

Best Python code snippet using tempest_python

test_api_version_request.py

Source:test_api_version_request.py Github

copy

Full Screen

...15from nova import exception16from nova import test17class APIVersionRequestTests(test.NoDBTestCase):18 def test_valid_version_strings(self):19 def _test_string(version, exp_major, exp_minor):20 v = api_version_request.APIVersionRequest(version)21 self.assertEqual(v.ver_major, exp_major)22 self.assertEqual(v.ver_minor, exp_minor)23 _test_string("1.1", 1, 1)24 _test_string("2.10", 2, 10)25 _test_string("5.234", 5, 234)26 _test_string("12.5", 12, 5)27 _test_string("2.0", 2, 0)28 _test_string("2.200", 2, 200)29 def test_null_version(self):30 v = api_version_request.APIVersionRequest()31 self.assertTrue(v.is_null())32 def test_invalid_version_strings(self):33 self.assertRaises(exception.InvalidAPIVersionString,34 api_version_request.APIVersionRequest, "2")35 self.assertRaises(exception.InvalidAPIVersionString,36 api_version_request.APIVersionRequest, "200")37 self.assertRaises(exception.InvalidAPIVersionString,38 api_version_request.APIVersionRequest, "2.1.4")39 self.assertRaises(exception.InvalidAPIVersionString,40 api_version_request.APIVersionRequest, "200.23.66.3")41 self.assertRaises(exception.InvalidAPIVersionString,42 api_version_request.APIVersionRequest, "5 .3")...

Full Screen

Full Screen

vocabularies_test.py

Source:vocabularies_test.py Github

copy

Full Screen

1# Copyright 2020 The T5 Authors.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14"""Tests for t5.data.vocabularies."""15from absl.testing import absltest16from t5.data import test_utils17from t5.data import vocabularies18import tensorflow.compat.v2 as tf19tf.compat.v1.enable_eager_execution()20mock = absltest.mock21_UNK_STRING = b" \xe2\x81\x87 "22_TEST_STRING = b"this is a test"23_TEST_TOKENS = (11, 8, 6, 3, 8, 6, 3, 5, 10)24_TEST_BYTE_IDS = \25 (119, 107, 108, 118, 35, 108, 118, 35, 100, 35, 119, 104, 118, 119)26class SentencepieceVocabularyTest(absltest.TestCase):27 def test_vocab(self):28 vocab = test_utils.sentencepiece_vocab()29 self.assertEqual(26, vocab.vocab_size)30 self.assertSequenceEqual(_TEST_TOKENS, vocab.encode(_TEST_STRING))31 self.assertEqual(32 _TEST_STRING,33 tf.compat.as_bytes(vocab.decode(_TEST_TOKENS)))34 self.assertSequenceEqual(35 _TEST_TOKENS,36 tuple(vocab.encode_tf(_TEST_STRING).numpy()))37 self.assertEqual(38 _TEST_STRING,39 vocab.decode_tf(_TEST_TOKENS).numpy())40 def test_extra_ids(self):41 vocab = test_utils.sentencepiece_vocab(extra_ids=10)42 self.assertEqual(36, vocab.vocab_size)43 self.assertEqual("v", vocab.decode([25]))44 self.assertEqual(_UNK_STRING, tf.compat.as_bytes(vocab.decode([35])))45 self.assertEqual(_UNK_STRING, vocab.decode_tf([35]).numpy())46 def test_equal(self):47 vocab1 = test_utils.sentencepiece_vocab()48 vocab2 = test_utils.sentencepiece_vocab()49 self.assertEqual(vocab1, vocab2)50 def test_not_equal(self):51 vocab1 = test_utils.sentencepiece_vocab()52 vocab2 = test_utils.sentencepiece_vocab(10)53 self.assertNotEqual(vocab1, vocab2)54class ByteVocabularyTest(absltest.TestCase):55 def test_vocab(self):56 vocab = vocabularies.ByteVocabulary()57 self.assertEqual(259, vocab.vocab_size)58 self.assertSequenceEqual(59 _TEST_BYTE_IDS,60 vocab.encode(_TEST_STRING.decode()))61 self.assertEqual(62 _TEST_STRING,63 tf.compat.as_bytes(vocab.decode(_TEST_BYTE_IDS)))64 self.assertEqual(65 _TEST_BYTE_IDS,66 tuple(vocab.encode_tf(_TEST_STRING).numpy()))67 self.assertEqual(68 _TEST_STRING,69 vocab.decode_tf(_TEST_BYTE_IDS).numpy())70 def test_extra_ids(self):71 vocab = vocabularies.ByteVocabulary(extra_ids=10)72 self.assertEqual(269, vocab.vocab_size)73 self.assertEqual("a", vocab.decode([100]))74 self.assertEqual("", vocab.decode([268]))75 def test_out_of_vocab(self):76 vocab = vocabularies.ByteVocabulary()77 self.assertEqual(259, vocab.vocab_size)78 self.assertEqual("", vocab.decode([260]))79 def test_equal(self):80 vocab1 = vocabularies.ByteVocabulary()81 vocab2 = vocabularies.ByteVocabulary()82 self.assertEqual(vocab1, vocab2)83 def test_not_equal(self):84 vocab1 = vocabularies.ByteVocabulary()85 vocab2 = vocabularies.ByteVocabulary(10)86 self.assertNotEqual(vocab1, vocab2)87if __name__ == "__main__":...

Full Screen

Full Screen

test_etreesource.py

Source:test_etreesource.py Github

copy

Full Screen

...33 assert_true(source._opened is None)34 assert_true(src is f)35 assert_true(src.closed is True)36 def test_string(self):37 self._test_string('\n<tag>content</tag>\n')38 def test_byte_string(self):39 self._test_string(b'\n<tag>content</tag>')40 self._test_string(u'<tag>hyv\xe4</tag>'.encode('utf8'))41 self._test_string(u'<?xml version="1.0" encoding="Latin1"?>\n'42 u'<tag>hyv\xe4</tag>'.encode('latin-1'), 'latin-1')43 def test_unicode_string(self):44 self._test_string(u'\n<tag>hyv\xe4</tag>\n')45 self._test_string(u'<?xml version="1.0" encoding="latin1"?>\n'46 u'<tag>hyv\xe4</tag>', 'latin-1')47 self._test_string(u"<?xml version='1.0' encoding='iso-8859-1' standalone='yes'?>\n"48 u"<tag>hyv\xe4</tag>", 'latin-1')49 def _test_string(self, xml, encoding='UTF-8'):50 source = ETSource(xml)51 with source as src:52 content = src.read()53 if IRONPYTHON_WITH_BROKEN_ETREE:54 content = content.encode(encoding)55 expected = xml if isinstance(xml, bytes) else xml.encode(encoding)56 assert_equal(content, expected)57 self._verify_string_representation(source, '<in-memory file>')58 assert_true(source._opened.closed)59 with ETSource(xml) as src:60 assert_equal(ET.parse(src).getroot().tag, 'tag')61 def test_non_ascii_string_repr(self):62 self._verify_string_representation(ETSource(u'\xe4'), u'\xe4')63 def _verify_string_representation(self, source, expected):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful