• Jérome Perrin's avatar
    tests: stop using deprecated unittest.makeSuite · 054896eb
    Jérome Perrin authored
    done with:
    
    ```py
    import libcst as cst
    import sys
    
    class RewriteMakeSuite(cst.CSTTransformer):
        def leave_Call(self, original_node: cst.Call, updated_node: cst.Call) -> cst.BaseExpression:
            func = updated_node.func
            if isinstance(func, cst.Attribute) and isinstance(func.value, cst.Name):
                if func.value.value == "unittest" and func.attr.value == "makeSuite":
                    first_arg = updated_node.args[0]
    
                    # check second argument
                    if len(updated_node.args) > 1:
                        second = updated_node.args[1].value
                        if isinstance(second, cst.SimpleString):
                            val = second.evaluated_value
                            if val != "test":
                                print(f"ERROR: unexpected second argument {second.code!r} in {original_node.code!r}", file=sys.stderr)
                                return updated_node
                        else:
                            print(...
    054896eb