Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ jobs:
done
cd ..

- name: Run tests
- name: Run unit tests
shell: bash
env:
IN_CONTAINER: "true"
PYTHONPATH: ${{ github.workspace }}/dist
PATH: "${{ github.workspace }}/dist:/usr/bin:$PATH"
run: |
python -m pytest
python -m pytest -m unit
23 changes: 23 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest

from monero import MoneroError

def pytest_runtest_call(item: pytest.Item):
# get not_supported marked
marker = item.get_closest_marker("not_supported")
if marker is None:
# marked not found
return

try:
# run test
item.runtest()
except MoneroError as e:
e_str = str(e).lower()
if "not supported" in e_str or "does not support" in e_str:
# Ok
pytest.xfail(str(e))
raise
else:
# fail test
pytest.fail("Expected test to fail")
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ log_cli_level = INFO
console_output_style = progress
testpaths =
tests
markers =
unit: fast unit tests, no external dependencies
integration: slow integration tests, requires external services
not_supported: expects not supported error
26 changes: 9 additions & 17 deletions src/cpp/py_monero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,19 +1538,7 @@ PYBIND11_MODULE(monero, m) {
MONERO_CATCH_AND_RETHROW(self.remove_listener(listener));
}, py::arg("listener"))
.def("get_listeners", [](PyMoneroWallet& self) {
try {
std::set<monero::monero_wallet_listener*> listeners = self.get_listeners();
std::vector<std::shared_ptr<monero::monero_wallet_listener>> result(listeners.size());

for(auto listener : listeners) {
result.emplace_back(listener);
}

return result;
}
catch (const std::exception& e) {
throw py::value_error(e.what());
}
MONERO_CATCH_AND_RETHROW(self.get_listeners());
})
.def("sync", [](PyMoneroWallet& self) {
MONERO_CATCH_AND_RETHROW(self.sync());
Expand Down Expand Up @@ -1800,9 +1788,13 @@ PYBIND11_MODULE(monero, m) {
MONERO_CATCH_AND_RETHROW(self.parse_payment_uri(uri));
}, py::arg("uri"))
.def("get_attribute", [](PyMoneroWallet& self, const std::string& key) {
std::string val;
self.get_attribute(key, val);
return val;
try {
std::string val;
self.get_attribute(key, val);
return val;
} catch (const std::exception& ex) {
throw PyMoneroError(ex.what());
}
}, py::arg("key"))
.def("set_attribute", [](PyMoneroWallet& self, const std::string& key, const std::string& val) {
MONERO_CATCH_AND_RETHROW(self.set_attribute(key, val));
Expand Down Expand Up @@ -1856,7 +1848,7 @@ PYBIND11_MODULE(monero, m) {
MONERO_CATCH_AND_RETHROW(self.save());
})
.def("close", [](monero::monero_wallet& self, bool save) {
self.close(save);
MONERO_CATCH_AND_RETHROW(self.close(save));
}, py::arg("save") = false);

// monero_wallet_keys
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/wallet/py_monero_wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class PyMoneroWallet : public monero::monero_wallet {
void remove_listener(monero_wallet_listener& listener) override {
m_listeners.erase(&listener);
}

std::set<monero_wallet_listener*> get_listeners() override {
return m_listeners;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/test_monero_connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
logger: logging.Logger = logging.getLogger("TestMoneroConnectionManager")

# TODO enable connection manager tests
@pytest.mark.skipif(True, reason="TODO")
@pytest.mark.skip(reason="TODO")
@pytest.mark.integration
class TestMoneroConnectionManager:
"""Connection manager integration tests"""

@pytest.fixture(autouse=True)
def setup_and_teardown(self, request: pytest.FixtureRequest):
Expand Down
Loading