diff --git a/knack/testsdk/base.py b/knack/testsdk/base.py index e6a07ef..83eb79f 100644 --- a/knack/testsdk/base.py +++ b/knack/testsdk/base.py @@ -25,9 +25,9 @@ class IntegrationTestBase(unittest.TestCase): - def __init__(self, cli, method_name): + def __init__(self, method_name): super().__init__(method_name) - self.cli = cli + self.cli = None self.diagnose = os.environ.get(ENV_TEST_DIAGNOSE, None) == 'True' def cmd(self, command, checks=None, expect_failure=False): @@ -81,8 +81,8 @@ class LiveTest(IntegrationTestBase): class ScenarioTest(IntegrationTestBase): # pylint: disable=too-many-instance-attributes - def __init__(self, cli, method_name, filter_headers=None): - super().__init__(cli, method_name) + def __init__(self, method_name, filter_headers=None): + super().__init__(method_name) self.name_replacer = GeneralNameReplacer() self.recording_processors = [LargeRequestBodyProcessor(), LargeResponseBodyProcessor(), diff --git a/examples/test_exapp b/tests/test_exapp.py old mode 100755 new mode 100644 similarity index 89% rename from examples/test_exapp rename to tests/test_exapp.py index bec82a3..30ff3f1 --- a/examples/test_exapp +++ b/tests/test_exapp.py @@ -31,9 +31,9 @@ def hello_command_handler(myarg=None, abc=None): class MyCommandsLoader(CLICommandsLoader): def load_command_table(self, args): - with CommandGroup(self, 'hello', '__main__#{}') as g: + with CommandGroup(self, 'hello', '{}#{{}}'.format(__name__)) as g: g.command('world', 'hello_command_handler', confirmation=True) - with CommandGroup(self, 'abc', '__main__#{}') as g: + with CommandGroup(self, 'abc', '{}#{{}}'.format(__name__)) as g: g.command('list', 'abc_list_command_handler') g.command('show', 'a_test_command_handler') return super(MyCommandsLoader, self).load_command_table(args) @@ -61,8 +61,9 @@ def load_arguments(self, command): class TestMyScenarios(ScenarioTest): - def __init__(self, method_name): - super(TestMyScenarios, self).__init__(mycli, method_name) + def setUp(self): + super().setUp() + self.cli = mycli def test_hello_world_yes(self): self.cmd('hello world --yes', checks=[