fixml.modules.code_analyzer.analyzers.python

Classes

CodeAnalyzer

Helper class that provides a standard way to create an ABC using

PythonASTCodeAnalyzer

Helper class that provides a standard way to create an ABC using

PythonNaiveCodeAnalyzer

Helper class that provides a standard way to create an ABC using

Functions

assert_have_read_content(f)

Module Contents

fixml.modules.code_analyzer.analyzers.python.assert_have_read_content(f)
class fixml.modules.code_analyzer.analyzers.python.CodeAnalyzer

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract read(file_path: str | pathlib.Path) None
abstract list_imported_packages()
abstract list_all_functions()
abstract contains_test()
_determine_encodings(file_path: str | pathlib.Path) str
class fixml.modules.code_analyzer.analyzers.python.PythonASTCodeAnalyzer

Bases: CodeAnalyzer

Helper class that provides a standard way to create an ABC using inheritance.

read(file_path: str | pathlib.Path)
_get_function_lineno_map()
list_imported_packages()
list_all_functions()
contains_test() bool

Check if the loaded content contains tests.

This assumes the file would be a Python file, and the tests are written using either pytest or unittest module.

This will check the following conditions: 1. If unittest or pytest modules is loaded, returns true. 2. If unittest or pytest modules is not loaded, check if there is a function name that starts with test (case-insensitive). If found, further check if the content of this function contain assertions i.e. assert - returns true if found.

class fixml.modules.code_analyzer.analyzers.python.PythonNaiveCodeAnalyzer

Bases: CodeAnalyzer

Helper class that provides a standard way to create an ABC using inheritance.

read(file_path: str | pathlib.Path)
_get_function_lineno_map()
list_imported_packages()
abstract list_all_functions()
contains_test()