Python

Sun 20 September 2020


Autospec will create a mock with each property and method mocked out, as opposed to just creating a mock and each specific attribute manually.

    mock_s = mock.create_autospec(subscriber.Subscriber)
    with mock.patch.object(myobj, "_create_subscriber", return_value=mock_s) as mock_foo:
new_local_repository(  
    name = "python_linux",
    path = "/usr",
    build_file_content = """
cc_library(  
    name = "python35-lib",
    srcs = ["lib/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5.so"],
    hdrs = glob(["include/python3.5/*.h"]),
    includes = ["include/python3.5"],
    visibility = ["//visibility:public"]
)
    """
)

Link against a system library

  cc_binary(
      name = "mpi",
      srcs = ["mpi.cc"],
    includes = ["/usr"],
    linkopts = [
        "-fopenmp",
    ],
    deps = [
        "@com_github_glog_glog//:glog",
    ],
)