Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issues with tests #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jwdinius
Copy link

@jwdinius jwdinius commented Oct 11, 2024

OS: Ubuntu 22.04
Python version: 3.7.6 (fresh Anaconda environment: conda create --name pytak python=3.7 -y; conda activate pytak)

I just checked out the repo and ran the automated tests. The procedure for installing from source did not include any documentation for how to run the tests, but inferring what the procedure is wasn't that difficult. From the root workspace folder, I installed the test dependencies with python3 -m pip install -r requirements_test.txt and then ran the pytest suite:

$ pytest tests
========================================================================= test session starts ==========================================================================
platform linux -- Python 3.7.6, pytest-7.4.4, pluggy-0.13.1
rootdir: /home/joe/work/github/pytak
plugins: ament-xmllint-0.12.11, ament-flake8-0.12.11, ament-copyright-0.12.11, ament-lint-0.12.11, launch-testing-1.0.6, launch-testing-ros-0.19.7, ament-pep257-0.12.11, anyio-2.2.0, cov-4.1.0, asyncio-0.21.2
asyncio: mode=strict
collected 41 items                                                                                                                                                     

tests/test_classes.py ..........                                                                                                                                 [ 24%]
tests/test_client_functions.py ..............                                                                                                                    [ 58%]
tests/test_functions.py ...........                                                                                                                              [ 85%]
tests/test_pref_packages.py .....                                                                                                                                [ 97%]
tests/test_pytak.py .                                                                                                                                            [100%]

=========================================================================== warnings summary ===========================================================================
tests/test_client_functions.py::test_protocol_factory_bad_url
  Warning: Invalid COT_URL=udp:localhost

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================================================== 41 passed, 1 warning in 0.37s =====================================================================

Reading the content of the tests though, it seems that the warning shouldn't really be a warning. The invalid URL is what is being tested, right?

With the new commit applied, I was able to run the suite of automated tests with no warnings or errors.

$ pytest tests
========================================================================= test session starts ==========================================================================
platform linux -- Python 3.7.6, pytest-7.4.4, pluggy-0.13.1
rootdir: /home/joe/work/github/pytak
plugins: ament-xmllint-0.12.11, ament-flake8-0.12.11, ament-copyright-0.12.11, ament-lint-0.12.11, launch-testing-1.0.6, launch-testing-ros-0.19.7, ament-pep257-0.12.11, anyio-2.2.0, cov-4.1.0, asyncio-0.21.2
asyncio: mode=strict
collected 41 items                                                                                                                                                     

tests/test_classes.py ..........                                                                                                                                 [ 24%]
tests/test_client_functions.py ..............                                                                                                                    [ 58%]
tests/test_functions.py ...........                                                                                                                              [ 85%]
tests/test_pref_packages.py .....                                                                                                                                [ 97%]
tests/test_pytak.py .                                                                                                                                            [100%]

========================================================================== 41 passed in 0.18s ==========================================================================

Running the suite of pytest tests yields a single warning:

```
tests/test_client_functions.py::test_protocol_factory_bad_url
  Warning: Invalid COT_URL=udp:localhost
```

Based on the context of the test, this warning shouldn't be flagged
as a warning at all. The warning is expected. This commit explicitly
catches the expected warning from pytest and marks the test as an
unconditional pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant