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
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
dtux
@dmtucker:matrix.org
[m]
I think it depends on the hook, some get passed the config/terminalwriter objects (e.g. pytest_configure or pytest_terminal_summary)
guilledk
@guilledk:matrix.org
[m]
managed to do it like this:
def pytest_sessionstart(session):

    terminal_reporter = session.config.pluginmanager.get_plugin('terminalreporter')
    capture_manager = session.config.pluginmanager.get_plugin('capturemanager')
    with capture_manager.global_and_fixture_disabled():

        terminal_reporter.write("connecting to docker daemon...", flush=True)
and at session finish:
def pytest_sessionfinish(session, exitstatus):

    terminal_reporter = session.config.pluginmanager.get_plugin('terminalreporter')
    capture_manager = session.config.pluginmanager.get_plugin('capturemanager')
    with capture_manager.global_and_fixture_disabled():
        vtestnet = get_testnet()
        if vtestnet and session.config.getoption('--keep-alive'):
            ports = waitfor(vtestnet, ('NetworkSettings', 'Ports', '8888/tcp'))
            container_port = ports[0]['HostPort']
            endpoint = f'http://localhost:{container_port}'

            terminal_reporter.ensure_newline()
            terminal_reporter.write(f"\nAccess the running testnet at {endpoint}\n")
            terminal_reporter.write("--keep-alive PRESENT, awaiting Ctrl+C...", flush=True)

            try:
                while True:
                    time.sleep(100000)

            except KeyboardInterrupt:
                pass

        terminal_reporter.write("\nstopping chain...", flush=True)

        get_exit_stack().pop_all().close()

        terminal_reporter.write(" done.", flush=True)
result:
guilledk
@guilledk:matrix.org
[m]
hey guys im running pytest 6.2.5 on python 3.10.0 and if I run pytest --help in the text it describes a command line option --log-cli of type bool
but if I try to use it as a flag or pass it a value pytest complains about that option not existing
[guille@hardPC pytest-eosio]$ sudo pytest --log-cli
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --log-cli
  inifile: /home/guille/Documents/pytest-eosio/pytest.ini
  rootdir: /home/guille/Documents/pytest-eosio
I know i can set it on a pytest.ini file, but im trying to setup a CI and it would be easier to pass it through command line arguments
1 reply
to have a run with logging enabled and one with it disabled
if its a confirmed issue im willing to contribute a patch but i want to confirm im not missing something obvious
buen_chico
@goodboy:matrix.org
[m]
guilledk: i saw that same thing recently
i think it may be a bug
or it's at least documented really poorly
dtux
@dmtucker:matrix.org
[m]
does it repro with an arg after? sudo pytest --log-cli .
buen_chico
@goodboy:matrix.org
[m]
oh yeah i'm noticing now they broke it out
guilledk
@guilledk:matrix.org
[m]
just tried it and yes
buen_chico
@goodboy:matrix.org
[m]
--log-cli-level=LOG_CLI_LEVEL
cli logging level.
--log-cli-format=LOG_CLI_FORMAT
log format as used by the logging module.
--log-cli-date-format=LOG_CLI_DATE_FORMAT
log date format as used by the logging module.
those are the only options now
guilledk
@guilledk:matrix.org
[m]
log_cli (bool):       enable log display during test run (also known as "live logging").
log_cli_level (string):
                        default value for --log-cli-level
  log_cli_format (string):
                        default value for --log-cli-format
  log_cli_date_format (string):
                        default value for --log-cli-date-format
im seeing this
buen_chico
@goodboy:matrix.org
[m]
i'm on 6.1.2
so yeah
still don't see it on latest
ohh
[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:
those opts are only for ini files
you know what right guilledk ?
guilledk
@guilledk:matrix.org
[m]
oh im dumb
that makes more sense
hehe
buen_chico
@goodboy:matrix.org
[m]
yeah don't think there's a cli flag
guilledk
@guilledk:matrix.org
[m]
what about having a cli flag as well?
buen_chico
@goodboy:matrix.org
[m]
i'm sure we'd take it
guilledk
@guilledk:matrix.org
[m]
ill write it up then
buen_chico
@goodboy:matrix.org
[m]
iirc i did disable this via some logic with a flag
one sec
something like that maybe?
you could slap in your own flag
in that case it was disabling the capture when the user passes a level