Best Python code snippet using assertpy_python
test_docstring.py
Source:test_docstring.py  
...28        return models.Docstring.get_non_obsolete().get(name=name)29class TestMerge(LocalTestCase):30    SIMPLE_DATA_1 = {31        'module(module)': '',32        'module.func_noop(callable)': 'text',33        'module.func_merge(callable)': 'text\n\nmore',34        'module.func_conflict(callable)': 'text',35        'module.func_delete(callable)': 'text',36        'docs(dir)': '',37        'docs/file_noop.rst(file)': 'text',38        'docs/file_merge.rst(file)': 'text\n\nmore',39        'docs/file_conflict.rst(file)': 'text',40    }41    SIMPLE_DATA_2 = {42        'module(module)': '',43        'module.func_noop(callable)': 'text',44        'module.func_merge(callable)': 'text\n\nmore 2',45        'module.func_conflict(callable)': 'text 2',46        'module.func_new(callable)': 'text',47        'docs(dir)': '',48        'docs/file_noop.rst(file)': 'text',49        'docs/file_merge.rst(file)': 'text\n\nmore 2',50        'docs/file_conflict.rst(file)': 'text 2',51        'docs/file_new.rst(file)': 'text',52    }53    def test_docstring_merging(self):54        """55        Check that simple docstring merging works56        """57        # initial pull...test_expected_exception.py
Source:test_expected_exception.py  
...107def test_expected_exception_arg_passing():108    assert_that(func_all).raises(RuntimeError).when_called_with('a', 'b', 3, 4, foo=1, bar=2, baz='dog').is_equal_to(109        "all err: arg1=a, arg2=b, args=(3, 4), kwargs=[('bar', 2), ('baz', 'dog'), ('foo', 1)]")110# helpers111def func_noop(*args, **kwargs):112    pass113def func_no_arg():114    raise RuntimeError('no arg err')115def func_one_arg(arg):116    raise RuntimeError('one arg err')117def func_multi_args(*args):118    raise RuntimeError('multi args err')119def func_kwargs(**kwargs):120    raise RuntimeError('kwargs err')121def func_all(arg1, arg2, *args, **kwargs):122    raise RuntimeError('all err: arg1=%s, arg2=%s, args=%s, kwargs=%s' % (arg1, arg2, args, [(k,kwargs[k]) for k in sorted(kwargs.keys())]))123class Foo(object):124    def bar(self):125        raise RuntimeError('method err')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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
