Code Monkey home page Code Monkey logo

Comments (5)

xflr6 avatar xflr6 commented on August 22, 2024

Thanks for the report.

Can you try with ./run-tests.py (https://graphviz.readthedocs.io/en/stable/development.html#tests). On my side the missing warning only happens when running with tox. I tried downgrading to different older versions (https://tox.wiki/en/legacy/changelog.html) but so far did not manage to find a version/setting where the warning is issued as intended.

from graphviz.

stanislavlevin avatar stanislavlevin commented on August 22, 2024

I have checked it, the same.

Either the test or the code is incorrect (don't know why supported_number is hardcoded to 3 for render).

During the test 3 args are passed to graphviz.render()

[(['', 'pdf', 'nonfilepath'], ValueError, r'unknown engine'),

@_tools.deprecate_positional_args(supported_number=3)
def render(engine: str,

In this case supported_number == len(args), the warning is not emitted:

graphviz/graphviz/_tools.py

Lines 153 to 169 in 6fe8c4e

if len(args) > supported_number:
call_args = zip(argnames, args)
supported = itertools.islice(call_args, supported_number)
supported = dict(supported)
deprecated = dict(call_args)
assert deprecated
func_name = func.__name__.lstrip('_')
func_name, sep, rest = func_name.partition('_legacy')
assert not set or not rest
wanted = ', '.join(f'{name}={value!r}'
for name, value in deprecated.items())
warnings.warn(f'The signature of {func.__name__} will be reduced'
f' to {supported_number} positional args'
f' {list(supported)}: pass {wanted}'
' as keyword arg(s)',
stacklevel=stacklevel,
category=category)

The warning pytest.deprecated_call catches in this test under certain circumstances is some different warning, not the expected one and completely unrelated. The warning message can be check with match:

https://docs.pytest.org/en/stable/reference/reference.html#pytest-deprecated-call

In the context manager form you may use the keyword argument match to assert that the warning matches a text or regex.

from graphviz.

xflr6 avatar xflr6 commented on August 22, 2024

Thank you very much for digging in: it did not occurr to me that the test was indeed incorrect (only visible in tox).

from graphviz.

stanislavlevin avatar stanislavlevin commented on August 22, 2024

Thanks, the fix has been verified 👍

from graphviz.

xflr6 avatar xflr6 commented on August 22, 2024

Great, improved the messages (ignore cls and self, use singular) and their matching in the tests in e5578d3.

from graphviz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.