How to use test_import_alias method in avocado

Best Python code snippet using avocado_python

test_basic.py

Source:test_basic.py Github

copy

Full Screen

...17 foo()'''18 self.checkDeprecatedUses(19 code,20 [('foo', '<>', 8, 4, None), ('foo', '<>', 10, 0, None)])21 def test_import_alias(self):22 code = '''23 import decoratortest as dec24 @dec.deprecated25 def foo(): pass26 def bar():27 foo()28 foo()'''29 self.checkDeprecatedUses(30 code,31 [('foo', '<>', 8, 4, None), ('foo', '<>', 10, 0, None)])32 def test_import_from(self):33 code = '''34 from decoratortest import deprecated35 @deprecated36 def foo(): pass37 def bar():38 foo()39 foo()'''40 self.checkDeprecatedUses(41 code,42 [('foo', '<>', 8, 4, None), ('foo', '<>', 10, 0, None)])43 def test_import_from_alias(self):44 code = '''45 from decoratortest import deprecated as dp46 @dp47 def foo(): pass48 def bar():49 foo()50 foo()'''51 self.checkDeprecatedUses(52 code,53 [('foo', '<>', 8, 4, None), ('foo', '<>', 10, 0, None)])54 def test_call_from_deprecated(self):55 code = '''56 from decoratortest import deprecated as dp57 @dp58 def foo(): pass59 @dp60 def bar():61 foo()62 foo()'''63 self.checkDeprecatedUses(64 code,65 [('foo', '<>', 9, 4, None), ('foo', '<>', 11, 0, None)])66 def test_import_from_same_module_and_decorator(self):67 code = '''68 from deprecated import deprecated69 @deprecated70 def foo(): pass71 def bar():72 foo()73 foo()'''74 self.checkDeprecatedUses(75 code,76 [('foo', '<>', 8, 4, None), ('foo', '<>', 10, 0, None)],77 ('deprecated', 'deprecated'))78class TestClassBasic(TestCase):79 def checkDeprecatedUses(self, code, expected_output):80 sio = StringIO(dedent(code))81 output = memestra.memestra(sio, ('decoratortest', 'deprecated'), None)82 self.assertEqual(output, expected_output)83 def test_import(self):84 code = '''85 import decoratortest86 @decoratortest.deprecated87 class foo: pass88 def bar():89 foo()90 foo()'''91 self.checkDeprecatedUses(92 code,93 [('foo', '<>', 8, 4, None), ('foo', '<>', 10, 0, None)])94 def test_import_alias(self):95 code = '''96 import decoratortest as dec97 @dec.deprecated98 class foo: pass99 def bar():100 foo()101 foo()'''102 self.checkDeprecatedUses(103 code,104 [('foo', '<>', 8, 4, None), ('foo', '<>', 10, 0, None)])105 def test_import_from(self):106 code = '''107 from decoratortest import deprecated108 @deprecated...

Full Screen

Full Screen

test_submodules.py

Source:test_submodules.py Github

copy

Full Screen

...5 "mypath", module_import=[str])6 def test_submodule_import(self):7 self.run_test('def submodule_import(l): import os.path; return os.path.join("lili", l)',8 "mypath", submodule_import=[str])9 def test_import_alias(self):10 self.run_test('def import_alias(l): import os.path as p; return p.join("lili", l)',11 "mypath", import_alias=[str])12 def test_function_import(self):13 self.run_test('def function_import(l): from os.path import join; return join("lili", l)',14 "mypath", function_import=[str])15 def test_function_import_alias(self):16 self.run_test('def function_import_alias(l): from os.path import join as j; return j("lili", l)',...

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 avocado 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