[Python] Unit test python for gatttool commands?

Discussão em 'Python' iniciado por Stack, Junho 19, 2025.

  1. Stack

    Stack Membro Participativo

    I am developing in python. My code calls terminal commands. I want to make unit tests for those functions. How do I test if terminal commands are working properly? Also I establish a bluetooth connection with gatt commands. How do I test functions building upon that?


    import pexpect

    MAC = "00:80:41:AE:fD:7C"

    def connect():
    gatt = pexpect.spawn("sudo gatttool -I")
    gatt.sendline("connect " + MAC)
    gatt.expect("Connection successful")
    def send(x):
    connect()
    gatt.sendline( f"char-write-req 0x000c {x}0" )
    gatt.expect("Characteristic value was written successfully")

    send("ff")

    Continue reading...

Compartilhe esta Página