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

Tests failing on main - Fedora 40 Python 3.12.5 #380

Closed
5 tasks done
fohrloop opened this issue Sep 16, 2024 · 1 comment · Fixed by #381
Closed
5 tasks done

Tests failing on main - Fedora 40 Python 3.12.5 #380

fohrloop opened this issue Sep 16, 2024 · 1 comment · Fixed by #381

Comments

@fohrloop
Copy link
Owner

fohrloop commented Sep 16, 2024

Just tried running tests on latest commit on main (6b3b0f8), and here's what I get:

inv test
❯ inv test output
Running:  env -u DBUS_SESSION_BUS_ADDRESS python -m pytest -W error --cov-branch --cov ./src --cov-fail-under=100 
ImportError while loading conftest '/home/fohrloop/code/wakepy/tests/conftest.py'.
tests/conftest.py:6: in <module>
    from tests.unit.test_core.testmethods import TestMethod
tests/unit/test_core/testmethods.py:41: in <module>
    from wakepy.core import PlatformType
src/wakepy/__init__.py:9: in <module>
    from . import methods as methods
src/wakepy/methods/__init__.py:29: in <module>
    from . import _testing as _testing
src/wakepy/methods/_testing.py:5: in <module>
    from wakepy.core import Method, PlatformType
src/wakepy/core/__init__.py:17: in <module>
    from .method import Method as Method
E     File "/home/fohrloop/code/wakepy/src/wakepy/core/method.py", line 73
E       """Lists the platforms the Method supports. If the current platform is not
E       ^^^
E   SyntaxError: invalid escape sequence '\*'
Running:  coverage html && python -m webbrowser -t htmlcov/index.html 
No data to report.

if the SyntaxError: invalid escape sequence '\*' above is fixed, there's a set of tests which still fail:

inv tests still failing
FAILED tests/integration/test_dbus_adapters.py::TestJeepneyCalculatorService::test_wrong_signature - pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0>
FAILED tests/integration/test_dbus_adapters.py::TestJeepneyDbusAdapter::test_close_connections - pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0>
ERROR tests/integration/test_dbus_adapters.py::TestJeepneyDbusAdapter::test_adapter_caching - pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0>

The strange thing is that the commit, which was from #379 , had normal CI pipelines checks which all passed.

Tasks

  • Find out why the tests are failing locally, but not in the pipelines.
  • Make the pipelines fail if there are Warnings. They already do. The warning was emitted only with the --cov flag so it's somehow related to coverage calculation, and it was not reproducible in other means.
  • If possible, make the pipelines fail with the sockets related PytestUnraisableExceptionWarnings Not feasible/possible. Added a test for the warnings filter regex that makes sure the Ubuntu and Fedora 40 versions are handled.
  • Fix the SyntaxWarning
  • Fix the PytestUnraisableExceptionWarning
@fohrloop
Copy link
Owner Author

fohrloop commented Sep 17, 2024

Debugging information

Running python -m pytest does not reproduce the error, since they're all caused by a Warning and -W error flag. The -W error is used in the inv test command.

About the SyntaxWarning

The invalid escape sequence '\*' is actually in the PR 379 pipelines output but that just did not fail the pipelines. Investigating why, as warnings should be treated as exceptions. The command with the warning was:

.tox/3.12/bin/python -m pytest -W error --cov-branch --cov /home/runner/work/wakepy/wakepy/.tox/3.12/lib/python3.12/site-packages/wakepy --cov-fail-under=100

This can be reproduced also locally, with

python -m pytest  --cov ./src

The other flags seem not to have any effect, and --cov is required to get the

tests/unit/test_methods/test_macos.py ....                                                                                                [ 92%]
tests/unit/test_modes.py ....................                                                                                             [100%]<unknown>:73: SyntaxWarning: invalid escape sequence '\*'
/home/fohrloop/code/wakepy/src/wakepy/core/method.py:73: SyntaxWarning: invalid escape sequence '\*'
  """Lists the platforms the Method supports. If the current platform is not

Seems that wakepy users are unaffected; there's no SyntaxWarning when importing:

In [1]: import wakepy

In [2]: from wakepy import Method

In [3]: from wakepy.core.method import Method

Could not also get any SyntaxWarning when playing around with the Method in an interactive shell. This seems to be not an issue. Going to simply remove the warning by fixing the string.

About pytest.PytestUnraisableExceptionWarning

These all occur in the tests/integration/test_dbus_adapters.py. The Warnings are actually expected, and they are have nothing to do with wakepy functionality, but they are only present in the integration tests, where a real DBus service is used temporarily. This arrangement has either some small bug, or it has a feature that some sockets are not closed. But as it's only part of the DBus service in the tests, it does not affect any wakepy users and the warning is just ignored.

There is a warning filter in tests/integration/test_dbus_adapters.py using pytestmark:

pytestmark = pytest.mark.filterwarnings(
    r"ignore:unclosed.*raddr=b'\\x00/tmp/dbus-.*:ResourceWarning"
)

and it says it's filtering warnings such as

ResourceWarning: unclosed <socket.socket fd=14, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, raddr=b'\x00/tmp/dbus-cTfPKAeBWk'> 

which was encountered on Ubuntu. Seems that on Fedora the error text is slightly different:

 ResourceWarning: unclosed <socket.socket fd=14, family=1, type=1, proto=0, raddr=/tmp/dbus-WkEJOPjiAu>

which is not captured by the regex. So the fix here is just to fix the regex to also ignore warnings on Fedora, and perhaps improve documentation a bit.

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 a pull request may close this issue.

1 participant