From 4647fbbc814929af232e5667f3e220e51c68b04a Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Fri, 1 Sep 2023 09:27:14 +0200 Subject: [PATCH] Add pytest basic tests and fix import to be coherent with README (#3) --- .github/workflows/ci.yml | 4 ++++ ci_env.yml | 1 + src/resolve_robotics_uri_py/__init__.py | 1 + test/test_resolve_robotics_uri_py.py | 6 ++++++ 4 files changed, 12 insertions(+) create mode 100644 test/test_resolve_robotics_uri_py.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0257642..7c58e20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,10 @@ jobs: - name: Import the package shell: bash -l {0} run: python -c "import resolve_robotics_uri_py" + + - name: Run the Python tests + shell: bash -l {0} + run: pytest # This test requires the conda-forge::icub-models, # robotology::ergocub-software and diff --git a/ci_env.yml b/ci_env.yml index 521578f..251db43 100644 --- a/ci_env.yml +++ b/ci_env.yml @@ -6,6 +6,7 @@ channels: dependencies: - python - pip + - pytest # packages that ship URDFs used to test - icub-models - ergocub-software diff --git a/src/resolve_robotics_uri_py/__init__.py b/src/resolve_robotics_uri_py/__init__.py index e69de29..6caf6d5 100644 --- a/src/resolve_robotics_uri_py/__init__.py +++ b/src/resolve_robotics_uri_py/__init__.py @@ -0,0 +1 @@ +from .resolve_robotics_uri_py import resolve_robotics_uri diff --git a/test/test_resolve_robotics_uri_py.py b/test/test_resolve_robotics_uri_py.py new file mode 100644 index 0000000..589ac3b --- /dev/null +++ b/test/test_resolve_robotics_uri_py.py @@ -0,0 +1,6 @@ +import resolve_robotics_uri_py +import pytest + +def test_non_existing_file(): + with pytest.raises(FileNotFoundError): + resolve_robotics_uri_py.resolve_robotics_uri("package://this/package/and/file/does/not.exist")