Skip to content

Luky - Script for easy (Rust/Cargo like) tests in Python

License

Notifications You must be signed in to change notification settings

GuilloteauQ/Luky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Luky

Luky - Script for easy (Rust/Cargo like) tests in Python

Installation

You can add this line to your .bashrc file to execute luky from everywhere:

alias luky="python3 path/to/luky.py"

How does it work ?

You have a test file for your Python project, with your test functions (no parameter) If you write #[test] before your function, and then run luky your_test_file.py, it will run your test function and print if it passed the test (complete its run) or if it failed.

Luky can take several Python files as input and can show the time of each test if you put the --time or the -t tags.

It also displays colors in the terminal by default. But if your terminal does not support colors, you can disable this with the --no-color tag.

There is an help that you can see with the --help or -h tags.

Example

my_tests.py:

#[test]
def stupid_test():
    assert 10 < 1

def untested_test():
     assert 1 == 1

#[test]
def test_add():
    assert 1 + 1 == 2

Then we run luky my_tests.py

And we get :

---------- my_tests.py ----------
[failed] : stupid_test
[passed] : test_add
Tests passed : 1 / 2

(The passed and failed are in green and red, but i couldn't figure out how to put color ...)

Limits

Works only in Python3 (Python2 incoming..) and on Linux (maybe MacOS).

Motivation

I've played a bit with Rust and with Cargo. A cool feature of the compiler is the test run. You can write tests functions within your program with the test macro, and they will not be executed during a standart run (cargo run), but only with a 'test run'(cargo test). I found this pretty cool, and then tried to do kind of the same in Python.

About

Luky - Script for easy (Rust/Cargo like) tests in Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages