Package: litio
A simple tool for testinglitiohow to useexample 1: The basicsinstallpipinstalllitiorunlitiorunlitio.ymlname:My Awesome Titletests:firsth-test:# test namepath:./tests/test1.py# path to python filefunctions:# functions list-pow:# function nameinputs:# inputs# arguments with name of parametersbase:2exponent:2expected:value:4# expected valuecomparator:Equalstest1.py:defpow(base,exponent):returnbase**exponentexample 2: If something fails?test2.py:defpow(base,exponent):returnbase/exponent# it's obviously not working.litio.yml:name:My Awesome Titleapi-key:YOUR_OPENAI_API_KEY_ENVIRONMENT_VARIABLE# the name of the environment variable, NOT THE API KEY!tests:failed-test:path:./tests/test2.pyfunctions:-pow:inputs:base:2exponent:2expected:value:4comparator:Equalsverbose:trueauto-fix:true# auto fix function using AI if call failshow auto-fix works?The "auto-fix" parameter instructs litio to use artificial intelligence to automatically repair and replace the function in the source code. If you prefer to confirm before consulting AI, you can use the "use-ai" parameter instead of "auto-fix."example 3: if a tests is not ready yet?test3.py:defcoming_soon():pass# it's not ready yetlitio.yml:name:My Awesome Titletests:not-ready-test:path:./tests/test3.pyfunctions:-coming_soon:expected:value:i am not ready yetcomparator:Equalsignore:true# ignore this test and continueLitio commandsrunAction: Runs the tests.parameters:--verbose(aliases:-V): Prints the full function call.--output(aliases:-o): The style of the output. It can becapybaraorclassicor you can install a custom style.--ai/--no-ai: enable/disable auto-fix using AI.installAction: Installs a Litio package.parameters:module: The name of the module to install, must be in formatauthor/moduleorauthor/module@version.--upgrade(aliases:-u): install the latest version of the module.uninstallAction: Uninstalls a Litio package.parameters:module: The name of the module to uninstall, must be in formatauthor/module.Litio config file referenceThe config file must be in YAML format and namedlitio.ymlnameparamaterThenameparameter is the title of the config file.api-keyparameterTheapi-keyparameter is the name of the environment variable that contains the OpenAI API key, NOT THE API KEY!output-styleparameterTheoutput-styleparameter is the style of the output. It can becapybaraorclassicfor now.testsparameterThetestsparameter is a dictionary of tests.Tests structureThe test name is the name of the test.Thepathparameter is the path to the Python file that contains the functions, methods or classmethods to test.Thefunctionsparameter is a list of functions to test.Looks like this:...tests:first-test:path:./src/utils.pyfunctions:-add:# function name...Function structureThe function name is the name of the function.Theinputsparameter is a dictionary of inputs.Theexpectedparameter is a dictionary with expected value and comparator.Theverboseparameter is a boolean that indicates whether to print the full function call.Theauto-fixparameter is a boolean that indicates whether to use AI to automatically fix the function. Only can be used with theEqualscomparator.Theuse-aiparameter is a boolean that indicates whether to use AI to fix the function. Only can be used with theEqualscomparator.Theignoreparameter is a boolean that indicates whether to ignore the function.Looks like this:...tests:first-test:path:./src/utils.pyfunctions:-FUNCTION_NAME:# (e.g. subtract)inputs:a:1# arguments with name of parametersb:2# must be the same as the name of the parameterexpected:value:-1# expected valuecomparator:EqualsUsing methodsThe syntax for a method is the same as that of a function, except that you need to add the "instance" parameter with the values to instantiate an object of that class.Looks like this:...tests:first-test:path:./src/utils.pyfunctions:-Person.get_age:instance:name:Johnage:30expected:value:30comparator:EqualsThe expected parameterThecomparatorparameter is the way to compare the expected value.Thevalueparameter is the expected value.you can access the attributes of the returned object using the dot notation. Look like this:...-add_lists:inputs:a:[1,2]b:[3,4]expected:# the value returned is [1, 2, 3, 4]value.0:1# access to value[0]comparator:Equalsyou also can use ranges:...-add_lists:inputs:a:[1,2]b:[3,4]expected:# the value returned is [1, 2, 3, 4]value.1;3:1# access to the range value[1:3]# NOTE: use semicolon(;) to indicate the range(e.g. value.1;3), not the colon(:) because conflict with the yaml syntaxcomparator:Equalsyou can also use spacing in the range:...-add_lists:inputs:a:[1,2]b:[3,4]expected:value.;;2:[1,3]# access to value[::2]comparator:Equalsyou also can access to a key in the dictionary:...-add_dicts:inputs:a:{"a":1,"b":2}b:{"c":3,"d":4}expected:value.a:1comparator:Equalsyou also can use dot notation multiple times:...-add_dicts:inputs:a:{"a":{"b":1}}b:{"c":{"d":2}}expected:value.a.b:1# access to value["a"]["b"]comparator:Equalsif function returns an object, you can access to the attributes of that object using the dot notation:...-create_person_object:inputs:name:Johnage:30expected:value.name:John# access to value.namecomparator:EqualsWhat comparators are there?EqualsGreaterLessGreaterOrEqualLessOrEqualNotEqualsIsIsNotIsNoneIsNotNoneIsInstanceIsNotInstanceHow can i create a module?Every module must have alitio.pyfile in root directory.Example module for output styles:litio.pyimport...# your dependecies heredefmy_own_output_style(args):...# your code herelitio={'output':{'my-own-output-style-name':my_own_output_style}}When your module is ready to use, you can publish it to github and install it usinglitio install you/your-module-nameexample:litio install lizardwine/litio-packagelitio dictionary referenceyou can repleace any litio functionoutput: you can add and replace any output styleclassic: classic outputcapybara: capybara outputoptions: you can add and replace any option for litio command--version: shows the litio version and exitsub_commands: you can add and replace any sub commandrun: run the tests in litio.ymlinstall: install a moduleuninstall: uninstall a moduleutils: you can add and replace any utilityextract_function_code: extract the code of a function from a fileArgs: set self attributes from a dictionaryOutputArgs: an organizer for the output argumentsparams_to_dict: convert a list of parameters to a dictionaryeval_param_values: evaluate the values of a list of parametersKwargs: set self attributes from a keyword argumentstester: you can replace the tester functiontest: test a function with the given inputs and expected valuesai: you can add or replace any AI powered functionBugFixer: class for bug fixingfix_bug: fix a bug in a function with BugFixerIf you module has dependencies, you must add them inrequirements.txtfile in root directory.