Skip to content

TST: Ignore weird warning in devdeps#228

Merged
pllim merged 1 commit intospacetelescope:masterfrom
pllim:fix-dev
May 5, 2026
Merged

TST: Ignore weird warning in devdeps#228
pllim merged 1 commit intospacetelescope:masterfrom
pllim:fix-dev

Conversation

@pllim
Copy link
Copy Markdown
Contributor

@pllim pllim commented May 5, 2026

Description

This pull request is to address weird warning that appears in devdeps only

_________________________________ test_bb_5000 _________________________________

cls = <class 'astropy.units.format.generic.Generic'>
t = LexToken(UNIT,'flux',1,0)

    @classmethod
    def _get_unit(cls, t: LexToken) -> UnitBase:
        try:
>           return cls._validate_unit(t.value)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

../../.tox/py314-test-devdeps/lib/python3.14/site-packages/astropy/units/format/base.py:235: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'astropy.units.format.generic.Generic'>, s = 'flux'
deprecations = <DeprecatedUnitAction.WARN: 'warn'>

    @classmethod
    def _validate_unit(
        cls, s: str, deprecations: DeprecatedUnitAction = DeprecatedUnitAction.WARN
    ) -> UnitBase:
        if s in cls._unit_symbols:
            s = cls._unit_symbols[s]
    
        elif not s.isascii():
            if s[0].startswith("°"):
                s = "deg" if len(s) == 1 else "deg_" + s[1:]
            if len(s) > 1 and s[-1] in cls._unit_suffix_symbols:
                s = s[:-1] + cls._unit_suffix_symbols[s[-1]]
            elif s.endswith("R\N{INFINITY}"):
                s = s[:-2] + "Ry"
    
>       return cls._units[s]
               ^^^^^^^^^^^^^
E       KeyError: 'flux'

../../.tox/py314-test-devdeps/lib/python3.14/site-packages/astropy/units/format/generic.py:429: KeyError

During handling of the above exception, another exception occurred:

self = <tempfile._TemporaryFileCloser object at 0x7f5b5ea725d0>

    def __del__(self):
        close_called = self.close_called
        self.cleanup()
        if not close_called:
>           _warnings.warn(self.warn_message, ResourceWarning)
E           ResourceWarning: Implicitly cleaning up <HTTPError 404: 'Not Found'>

/opt/hostedtoolcache/Python/3.14.4/x64/lib/python3.14/tempfile.py:484: ResourceWarning

The above exception was the direct cause of the following exception:

cls = <class '_pytest.runner.CallInfo'>
func = <function call_and_report.<locals>.<lambda> at 0x7f5b5e9e2b90>
when = 'call'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: Callable[[], TResult],
        when: Literal["collect", "setup", "call", "teardown"],
        reraise: type[BaseException] | tuple[type[BaseException], ...] | None = None,
    ) -> CallInfo[TResult]:
        """Call func, wrapping the result in a CallInfo.
    
        :param func:
            The function to call. Called without arguments.
        :type func: Callable[[], _pytest.runner.TResult]
        :param when:
            The phase in which the function is called.
        :param reraise:
            Exception or exceptions that shall propagate if raised by the
            function, instead of being wrapped in the CallInfo.
        """
        excinfo = None
        instant = timing.Instant()
        try:
>           result: TResult | None = func()
                                     ^^^^^^

../../.tox/py314-test-devdeps/lib/python3.14/site-packages/_pytest/runner.py:353: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/_pytest/runner.py:245: in <lambda>
    lambda: runtest_hook(item=item, **kwds),
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/pluggy/_hooks.py:512: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/pluggy/_manager.py:120: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/_pytest/logging.py:850: in pytest_runtest_call
    yield
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/pluggy/_callers.py:53: in run_old_style_hookwrapper
    return result.get_result()
           ^^^^^^^^^^^^^^^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/pluggy/_callers.py:38: in run_old_style_hookwrapper
    res = yield
          ^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/_pytest/capture.py:900: in pytest_runtest_call
    return (yield)
            ^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/pluggy/_callers.py:53: in run_old_style_hookwrapper
    return result.get_result()
           ^^^^^^^^^^^^^^^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/pluggy/_callers.py:38: in run_old_style_hookwrapper
    res = yield
          ^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/_pytest/skipping.py:268: in pytest_runtest_call
    return (yield)
            ^^^^^
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/_pytest/unraisableexception.py:158: in pytest_runtest_call
    collect_unraisable(item.config)
../../.tox/py314-test-devdeps/lib/python3.14/site-packages/_pytest/unraisableexception.py:79: in collect_unraisable
    raise errors[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

config = <_pytest.config.Config object at 0x7f5b80fc8ec0>

    def collect_unraisable(config: Config) -> None:
        pop_unraisable = config.stash[unraisable_exceptions].pop
        errors: list[pytest.PytestUnraisableExceptionWarning | RuntimeError] = []
        meta = None
        hook_error = None
        try:
            while True:
                try:
                    meta = pop_unraisable()
                except IndexError:
                    break
    
                if isinstance(meta, BaseException):
                    hook_error = RuntimeError("Failed to process unraisable exception")
                    hook_error.__cause__ = meta
                    errors.append(hook_error)
                    continue
    
                msg = meta.msg
                try:
>                   warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E                   pytest.PytestUnraisableExceptionWarning: Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7f5b816864b0>: None

../../.tox/py314-test-devdeps/lib/python3.14/site-packages/_pytest/unraisableexception.py:67: PytestUnraisableExceptionWarning

Fixes #

@pllim pllim added this to the 1.6.0 milestone May 5, 2026
@pllim pllim added the testing label May 5, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.11%. Comparing base (2601dd7) to head (11e25e6).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #228      +/-   ##
==========================================
+ Coverage   84.07%   84.11%   +0.03%     
==========================================
  Files          13       13              
  Lines        1633     1637       +4     
==========================================
+ Hits         1373     1377       +4     
  Misses        260      260              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pllim pllim marked this pull request as ready for review May 5, 2026 23:47
@pllim pllim merged commit fbf997a into spacetelescope:master May 5, 2026
17 of 18 checks passed
@pllim pllim deleted the fix-dev branch May 5, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant