extern crate nafcodec_py;
extern crate pyo3;
use std::path::Path;
use pyo3::prelude::*;
use pyo3::types::PyDict;
use pyo3::types::PyList;
pub fn main() -> PyResult<()> {
let folder = Path::new(file!())
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap();
pyo3::prepare_freethreaded_python();
Python::with_gil(|py| {
let sys = py.import("sys")?;
sys.getattr("path")?
.downcast::<PyList>()?
.insert(0, folder)?;
let module = PyModule::new(py, "nafcodec.lib")?;
nafcodec_py::init(py, &module).unwrap();
sys.getattr("modules")?
.downcast::<PyDict>()?
.set_item("nafcodec.lib", &module)?;
let kwargs = PyDict::new(py);
kwargs.set_item("exit", false).unwrap();
kwargs.set_item("verbosity", 2u8).unwrap();
py.import("unittest").unwrap().call_method(
"TestProgram",
("nafcodec.tests",),
Some(&kwargs),
)?;
Ok(())
})
}