How to use the getgauge.parser.PythonFile function in getgauge

To help you get started, we’ve selected a few getgauge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getgauge / gauge-python / tests / test_handlers.py View on Github external
def load_content_steps(self, content):
        content = dedent(content)
        pf = PythonFile.parse("foo.py", content)
        self.assertIsNotNone(pf)
        loader.load_steps(pf)
github getgauge / gauge-python / tests / test_lsp_server.py View on Github external
def load_content_steps(self, content):
        content = dedent(content)
        pf = PythonFile.parse("foo.py", content)
        self.assertIsNotNone(pf)
        loader.load_steps(pf)
github getgauge / gauge-python / tests / test_static_loader.py View on Github external
def test_loader_reload_registry_for_given_content_with_empty_arg(self):
        content = dedent("""
            @step("print hello <>")
            def printf(arg1):
                print(arg1)
            """)
        load_steps(PythonFile.parse("foo.py", content))

        self.assertTrue(registry.is_implemented("print hello {}"))
github getgauge / gauge-python / tests / test_static_loader.py View on Github external
def test_loader_populates_registry_from_given_file_content(self):
        content = dedent("""
        @step("print hello")
        def printf():
            print("hello")


        @step("print .")
        def print_word(word):
            print(word)

        """)
        load_steps(PythonFile.parse("foo.py", content))

        self.assertTrue(registry.is_implemented("print hello"))
        self.assertTrue(registry.is_implemented("print {}."))
        self.assertEqual(len(registry.steps()), 2)
github getgauge / gauge-python / tests / test_static_loader.py View on Github external
def tearDown(self):
        PythonFile.select_python_parser()
github getgauge / gauge-python / tests / test_refactor.py View on Github external
def setUp(self):
        PythonFile.select_python_parser('parso')
        RefactorTests.setUp(self)
github getgauge / gauge-python / tests / test_refactor.py View on Github external
def tearDown(self):
        RefactorTests.tearDown(self)
        PythonFile.select_python_parser()
github getgauge / gauge-python / getgauge / refactor.py View on Github external
def refactor_step(request, response):
    if registry.has_multiple_impls(request.oldStepValue.stepValue):
        raise Exception('Multiple Implementation found for `{}`'.format(
            request.oldStepValue.parameterizedStepValue
        ))
    info = registry.get_info_for(request.oldStepValue.stepValue)
    impl_file = PythonFile.parse(info.file_name)
    diffs = impl_file.refactor_step(
        info.step_text,
        request.newStepValue.parameterizedStepValue,
        _new_parameter_positions(request),
    )
    content = impl_file.get_code()
    if request.saveChanges:
        with open(info.file_name, 'w') as f:
            f.write(content)
    response.success = True
    response.filesChanged.append(info.file_name)
    response.fileChanges.add(
        fileName=info.file_name,
        fileContent=content,  # FIXME: Remove deprecated field
        diffs=[TextDiff(span=Span(**d[0]), content=d[1]) for d in diffs],
    )
github getgauge / gauge-python / getgauge / static_loader.py View on Github external
def load_files(step_impl_dirs):
    for step_impl_dir in step_impl_dirs:
        for dirpath, _, files in os.walk(step_impl_dir):
                py_files = (os.path.join(dirpath, f) for f in files if f.endswith('.py'))
                for file_path in py_files:
                        pf = PythonFile.parse(file_path)
                        if pf:
                                load_steps(pf)
github getgauge / gauge-python / getgauge / static_loader.py View on Github external
def reload_steps(file_path, content=None):
    pf = PythonFile.parse(file_path, content)
    if pf:
        registry.remove_steps(file_path)
        load_steps(pf)