Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 31 2019 22:49
    RonnyPfannschmidt commented #4702
  • Jan 31 2019 22:25
    nicoddemus opened #4703
  • Jan 31 2019 22:12
    nicoddemus commented #4702
  • Jan 31 2019 21:58
    nicoddemus commented #4701
  • Jan 31 2019 21:22
    RonnyPfannschmidt commented #4701
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:20
    RonnyPfannschmidt labeled #4702
  • Jan 31 2019 21:19
    RonnyPfannschmidt commented #4702
  • Jan 31 2019 21:05
    wimglenn commented #4700
  • Jan 31 2019 20:47
    wimglenn commented #4699
  • Jan 31 2019 20:46
    astraw38 opened #4702
  • Jan 31 2019 20:44
    nicoddemus commented #4701
  • Jan 31 2019 19:45
    davidak commented #4701
  • Jan 31 2019 19:10

    nicoddemus on features

    Preparing release version 4.2.0 Merge pull request #4696 from nā€¦ Merge pull request #4697 from nā€¦ (compare)

  • Jan 31 2019 19:10
    nicoddemus closed #4697
  • Jan 31 2019 19:10
    nicoddemus labeled #4701
  • Jan 31 2019 19:10
    nicoddemus labeled #4701
lord_fomo
@goodboy:matrix.org
[m]
hmm maybe we removed that actually?
either way as long as your instances are singletons you should be able to do what i showed ^
tucked
@tucked:matrix.org
[m]

ya... i dont have a registry w names but i kinda just realized that i may want one (because it would allow me to prevent one plugin from raising another plugin's registered check). not too sure about how i'm doing it now anyways because it's in a arbitrary class (as opposed to something aware of the plugin system)

class Check:

  IDs: Dict[str, List[Any]]

  def __init__(self, *ids: str):
    for id_ in ids:
      if id_ not in self.IDs:
        raise Exception("not registered")
    ...

  @classmethod
  def register(cls, registrant: Any, ids: List[str]):
    for id_ in ids:
      if id_ in cls.IDs:
        raise Exception("already registered")
      else:
        cls.IDs[id_] = registrant

thinking i might move this to my config object (which has the plugin_manager as an attr) so as to be more plugin-aware

lord_fomo
@goodboy:matrix.org
[m]
yeah so i can't find any examples of non-instances in tests:
https://github.com/pytest-dev/pluggy/search?q=.register%28
but i do recall having used it, and eyeballing the code there's no reason it won't work.
i'm pretty sure methods should just work as well you'll just get the self being a class ref
but i think that's just python types
that is the symmetry of the self stuff iirc
[nav] In [7]: class C:
         ...:     @classmethod
         ...:     def meth(cls):
         ...:         print(cls)

[nav] In [8]: C.meth()
<class '__main__.C'>
that at least should work
@staticmethod as well
but you can't on plain methods
[nav] In [10]: class C:
          ...:     def meth(cls):
          ...:         print(cls)

[ins] In [11]: C.meth(C)
<class '__main__.C'>
will work, but obviously then you have to bind in the self=C on the hook call
which is pretty ugly
anyway hopefully that didn't confuse you more
but the way it is makes sense
for instances
David Tucker
@tucked:matrix.org
[m]
ya, i agree... (i think you haven't lost me šŸ˜‹ )
lord_fomo
@goodboy:matrix.org
[m]
kk
that's good
šŸ„ā€ā™‚ļø
yeah pluggy is a pretty minimal system
it's basically just a fan-out function call with variable "consumers" of that call
David Tucker
@tucked:matrix.org
[m]
ya... it's pretty great šŸ˜Ž
lord_fomo
@goodboy:matrix.org
[m]
šŸ‘ļø
aight i'm onto bourbon
gl with your thing
David Tucker
@tucked:matrix.org
[m]
thanks!
lord_fomo
@goodboy:matrix.org
[m]
David Tucker: oh and btw if you end up getting something working with class / static methods please do put up a PR for both minimal tests and docs
i see no reason not to make this behavior up front since we are trying to emphasize Callable duck-typing, not specific types in python
David Tucker
@tucked:matrix.org
[m]
right on... probably won't need that route, but will do if that changes
David Tucker
@tucked:matrix.org
[m]

we've got a package that is a pytest plugin, but also includes tests. right now, we run those tests by defining a custom entry_point which just calls

sys.exit(pytest.main([resource_filename("mypkg", "tests")] + argv))

(it doesn't use --pyargs because of https://github.com/pytest-dev/pytest/issues/1596)
the problem is that those tests show up as ../usr/local/lib/python2.7/site-packages/mypkg/tests/test_whatever::test_whatever_foo (2.7 i know, know... working on it)

would it be sane to have our entry_point do this instead?

os.chdir(resource_filename("mypkg", "tests"))
sys.exit(pytest.main(argv))
tucked
@tucked:matrix.org
[m]
hmmm... actually i think we can get around that issue by registering as a plugin in setup.py instead of relying on conftest.py being discovered.
next Q tho: can node IDs be used with --pyargs?
David Tucker
@tucked:matrix.org
[m]
heh... they are different! pytest --pyargs mypkg.tests.test_whatever::test_whatever_foo
Ronny
@ronnypfannschmidt:matrix.org
[m]
Py args and node ids don't play well
dtux
@dmtucker:matrix.org
[m]
interesting... well, it beats our previous solution (hard code the installed test dir and rely on -k instead of node IDs), but it would be cooler if the same/standard node IDs could be used
Ronny
@ronnypfannschmidt:matrix.org
[m]
the concept thats necessary to do this better is "test roots" which may be on pythonpath
Sorin Sbarnea
@ssbarnea
thanks for changing pluggy<2, now I only need to wait for the next release.
Henry Schreiner
@henryiii
Is it hard to have an optional, default off test (vs. optional, default on, easy with markers)? The only plugin I can find for it has been untouched for 2 years and a bit broken.
Ronny
@ronnypfannschmidt:matrix.org
[m]
@henryiii the slow test examples show
Ronny
@ronnypfannschmidt:matrix.org
[m]
:point_up: Edit: @henryiii the slow test examples show
guilledk
@guilledk:matrix.org
[m]
hey guys, im writing a plugin and i need to display some output from a hook
im doing it from a fixture using this code:
terminal_reporter = request.config.pluginmanager.get_plugin('terminalreporter')
capture_manager = request.config.pluginmanager.get_plugin('capturemanager')
with capture_manager.global_and_fixture_disabled():
    terminal_reporter.ensure_newline()
    terminal_reporter.write("TEST SESSION DONE, --keep-alive PRESENT, awaiting Ctrl+C...", flush=True)
i access the config to disable capturing using the request fixture
but how can I do the same from a hook?
guilledk
@guilledk:matrix.org
[m]
the more general question would be how to print output from a hook