How to use test_closed method in yandex-tank

Best Python code snippet using yandex-tank

test_descriptors.py

Source:test_descriptors.py Github

copy

Full Screen

1import pytest2import dataclasses3import re4from shell_parser.ast import CommandDescriptors, CommandDescriptor, CommandDescriptorClosed, CommandFileDescriptor5from shell_parser.ast import InvalidDescriptorDataException, InvalidFileDescriptorException6from shell_parser.ast import DescriptorRead, DescriptorWrite, RedirectionInput, RedirectionOutput, RedirectionAppend7from shell_parser.ast import File, DefaultFile, StdinTarget, StdoutTarget, StderrTarget8def make_match(msg: str) -> str:9 return "^" + re.escape(msg) + "$"10def test_missing_compulsory_data():11 with pytest.raises(TypeError, match=make_match("__init__() missing 2 required positional arguments: 'mode' and 'descriptor'")):12 CommandDescriptor()13 with pytest.raises(TypeError, match=make_match("__init__() missing 1 required positional argument: 'descriptor'")):14 CommandDescriptor(mode=DescriptorRead())15def test_invalid_descriptor_data():16 with pytest.raises(InvalidDescriptorDataException):17 file_target = File(name="test.txt")18 file_descriptor = CommandFileDescriptor(target=file_target, operator=RedirectionOutput())19 CommandDescriptor(mode=DescriptorRead(), descriptor=file_descriptor)20 with pytest.raises(InvalidDescriptorDataException):21 file_target = File(name="test.txt")22 file_descriptor = CommandFileDescriptor(target=file_target, operator=RedirectionAppend())23 CommandDescriptor(mode=DescriptorRead(), descriptor=file_descriptor)24 with pytest.raises(InvalidDescriptorDataException):25 file_target = File(name="test.txt")26 file_descriptor = CommandFileDescriptor(target=file_target, operator=RedirectionInput())27 CommandDescriptor(mode=DescriptorWrite(), descriptor=file_descriptor)28 with pytest.raises(InvalidDescriptorDataException):29 file_target = File(name="test.txt")30 file_descriptor = CommandFileDescriptor(target=file_target, operator=RedirectionInput())31 CommandDescriptor(mode=RedirectionInput(), descriptor=file_descriptor)32def test_immutability():33 file_target = File(name="test1.txt")34 default_file_target = DefaultFile(target=StdinTarget())35 file_descriptor = CommandFileDescriptor(target=file_target, operator=RedirectionOutput())36 descriptor = CommandDescriptor(mode=DescriptorWrite(), descriptor=file_descriptor)37 with pytest.raises(dataclasses.FrozenInstanceError):38 descriptor.mode = RedirectionOutput()39 with pytest.raises(dataclasses.FrozenInstanceError):40 descriptor.descriptor = CommandFileDescriptor(target=default_file_target, operator=RedirectionInput())41 with pytest.raises(dataclasses.FrozenInstanceError):42 descriptor.descriptor.target = default_file_target43 with pytest.raises(dataclasses.FrozenInstanceError):44 descriptor.descriptor.operator = RedirectionAppend()45 with pytest.raises(dataclasses.FrozenInstanceError):46 file_target.name = "test2.txt"47 with pytest.raises(dataclasses.FrozenInstanceError):48 default_file_target.target = StderrTarget()49def test_closed_descriptor():50 test_closed = CommandDescriptorClosed()51 duplicated_test_closed = test_closed.duplicate()52 assert duplicated_test_closed == test_closed53 # CommandDescriptorClosed doesn't store any state, so duplicating it54 # just returns the original object.55 assert duplicated_test_closed is test_closed56 with pytest.raises(dataclasses.FrozenInstanceError):57 test_closed.newattr = "newattr"58def test_descriptor_container():59 with pytest.raises(InvalidFileDescriptorException, match=make_match("File descriptors must be integers")):60 CommandDescriptors({"a": CommandDescriptorClosed()})61 with pytest.raises(InvalidFileDescriptorException, match=make_match("File descriptors must be integers")):62 CommandDescriptors({True: CommandDescriptorClosed(), 2: CommandDescriptorClosed()})63 with pytest.raises(InvalidFileDescriptorException, match=make_match("File descriptors must be integers")):64 CommandDescriptors({1: CommandDescriptorClosed(), None: CommandDescriptorClosed()})65 with pytest.raises(InvalidFileDescriptorException, match=make_match("File descriptors must not be negative")):66 CommandDescriptors({-1: CommandDescriptorClosed()})67 with pytest.raises(InvalidFileDescriptorException, match=make_match("File descriptors must not be negative")):...

Full Screen

Full Screen

selfdelimitedblob.py

Source:selfdelimitedblob.py Github

copy

Full Screen

...50 self.io_interface = io_interface51 self._closed = False52 self.reset()5354 def test_closed(self):55 if self._closed:56 raise RuntimeError("Storage is closed and can't perform any operation")5758 @property59 def store(self):60 self.test_closed()61 return self._store6263 @store.setter64 def store(self, value):65 self.test_closed()66 self._store = value6768 def reset(self):69 self.test_closed()70 self.id_ctr = 0 # first id will be 1 (the minimum allowed)71 self.store = {}7273 def __contains__(self, id):74 return id in self.store7576 def append(self, obj):77 self.id_ctr += 178 s = io.BytesIO()79 self.io_interface(s).write_obj(obj)80 self.store[self.id_ctr] = s.getvalue()81 return self.id_ctr8283 def read(self, id, **opts): ...

Full Screen

Full Screen

magma_hash_test.py

Source:magma_hash_test.py Github

copy

Full Screen

...11def hash_fundamental_group_presentation(M, index):12 G = magma(M.fundamental_group())13 return hash_magma_group(G, index)14 15def test_closed():16 out = ntools.DataOutFile('/tmp/snappy-out-' + version)17 for M in snappy.OrientableClosedCensus():18 out.write( [M, hash_fundamental_group_presentation(M, 8) ] )19test_closed()...

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 yandex-tank 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