profile
viewpoint

delete branch graingert/pytest

delete branch : fixture-yield-exit-stack

delete time in an hour

push eventpytest-dev/pytest

Thomas Grainger

commit sha c224c4f1d6aa90a20ff03aa75ed44328c843c644

de-emphasize request.addfinalizer

view details

Thomas Grainger

commit sha a96710dd8a143c588382cc5104acd6522e7426fe

demonstrate ExitStack assuming connect returns a context manager

view details

Thomas Grainger

commit sha 7440cece5915f31accf813ccd01890fe29711941

Merge pull request #5589 from graingert/fixture-yield-exit-stack de-emphasize request.addfinalizer Fixes #5587

view details

push time in an hour

PR merged pytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

<!-- Thanks for submitting a PR, your contribution is really appreciated!

Here is a quick checklist that should be present in PRs. (please delete this text from the final description, this is just a guideline) -->

  • [x] Target the master branch for bug fixes, documentation updates and trivial changes.
  • [ ] Target the features branch for new features and removals/deprecations.
  • [ ] Include documentation when adding new features.
  • [ ] Include new tests or update existing tests when applicable.

Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:

  • [ ] Create a new changelog file in the changelog folder, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.
  • [ ] Add yourself to AUTHORS in alphabetical order;

Fixes #5587

+48 -18

5 comments

1 changed file

graingert

pr closed time in an hour

issue closedpytest-dev/pytest

De-emphaze addfinalizer in favour of ExitStack

now that py2 support is dropped we should discourage addfinalizer and suggest people make their own ExitStack in a yield fixture

@pytest.fixture
def equipments():
    with contextlib.ExitStack() as exit_stack:
        r = []
        for port in ('C1', 'C3', 'C28'):
            equip = connect(port)
            exit_stack.callback(equip.disconnect)
            r.append(equip)
        yield r

closed time in an hour

graingert

issue commentadamchainz/patchy

a patchy interface to allow use in contexts

Hmm maybe it would be better to just document how people could do it themselves with existing patchy:

import contextlib
from concurrent import futures

import patchy

def sample():
    return 1

sample_ctx = ContextVar('sample', default=1)

patchy.patch(
    sample,
    f"""\
    @@ -1,2 +1,2 @@
    def sample():
    -    return 1
    +    return importlib.import_module({__name__!r}).sample_ctx.get()
    """,
)


def contextvar_context_manager(ctx):
    @contextlib.contextmanager
    def cm(update):
        token = ctx.set(update)
        try:
            yield
        finally:
            ctx.reset(token)

sample_ctx_context_manager = contextvar_context_manager(sample_ctx)

def run(patch):
    with sample_ctx_context_manager(9001) if patch else contextlib.nullcontext():
        return target()

with futures.ThreadPoolExecutor(max_workers=999) as executor:
    assert list(executor.map(run, [i % 2 for i in range(100)))) == [1, 9001, 1, 9001 ...]
graingert

comment created time in 5 hours

issue commentadamchainz/patchy

a patchy interface to allow use in contexts

eg it would have to replace .__code__ with something that delegated to a ContextVar that either ran the old code or the patch

graingert

comment created time in 5 hours

issue openedadamchainz/patchy

a patchy interface to allow use in contexts

import contextlib
from concurrent import futures

import patchy

def sample():
    return 1

patchy.prepare(
    sample,
    """\
    @@ -1,2 +1,2 @@
    def sample():
    -    return 1
    +    return 9001
    """,
)

def run(patch):
    with prepared_patch() if patch else contextlib.nullcontext():
        return target()

with futures.ThreadPoolExecutor(max_workers=999) as executor:
    assert list(executor.map(run, [i % 2 for i in range(100)))) == [1, 9001, 1, 9001 ...]

created time in 5 hours

issue commentvuejs/vue

.DS_Store files shipped in npm package

Or publish from CI rather than some Dev's local machine

graingert

comment created time in 6 hours

pull request commentpytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

@nicoddemus should I hit "Merge pull request" ? :shipit:

graingert

comment created time in 8 hours

Pull request review commentpytest-dev/pytest

[RFC] --import-mode: allow for "importlib" [ci skip]

 def pytest_addoption(parser):     group.addoption(         "--import-mode",         default="prepend",-        choices=["prepend", "append"],+        choices=["prepend", "append", "importlib"],         dest="importmode",         help="prepend/append to sys.path when importing test modules, "

I think this help string should be updated

blueyed

comment created time in 9 hours

Pull request review commentpytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

 Here's the ``equipments`` fixture changed to use ``addfinalizer`` for cleanup:     def equipments(request):         r = []         for port in ("C1", "C3", "C28"):-            equip = connect(port)-            request.addfinalizer(equip.disconnect)+            cm = connect(port)+            equip = cm.__enter__()+            request.addfinalizer(functools.partial(cm.__exit__, None, None, None))
def test_something():
    with contextlib.ExitStack as stack:
        setup_something()
        stack.callback(cleanup_something)
        assert sut()
graingert

comment created time in a day

issue commentsqlalchemy/sqlalchemy

transaction traceability in pg >= 10

trying to optimize for the case where we committed, it failed, but then it didn't actually fail, seems not worth it in the ORM.

This isn't a performance optimization, it's for correctness.

graingert

comment created time in a day

issue commentsqlalchemy/sqlalchemy

transaction traceability in pg >= 10

it implies when flush() catches an error

No only when commit or exit catches an error

graingert

comment created time in a day

issue commentsqlalchemy/sqlalchemy

transaction traceability in pg >= 10

You can't pick up where you left off, you just know if the transaction was committed or not

graingert

comment created time in a day

issue commentsqlalchemy/sqlalchemy

transaction traceability in pg >= 10

No this isn't it.

Consider executing:

BEGIN;
INSERT INTO user (name) VALUES ("example");
COMMIT; # you get a connection error here

How do you know if you inserted the record or not?

Also consider:

cm = sess.begin()
tx = cm.__enter__()
tx.execute("INSERT INTO user (name) VALUES ('example')")
cm.__exit__()
# application is kill -9'ed
f.write(f"job {jid} completed")

Now you're in a situation where you've completed the job in the database but your application log is out of sync

graingert

comment created time in a day

issue commentsqlalchemy/sqlalchemy

transaction traceability in pg >= 10

but it's not clear to me if you are suggesting that an error would not be raised at all.

Yeah sort of. Essentially with this feature it's possible to recover from a connection error just after issuing 'COMMIT'

It's also possible to recover from application error after issuing 'COMMIT' if the application maintains its own "write-intent journal file"

graingert

comment created time in a day

issue commentsqlalchemy/sqlalchemy

transaction traceability in pg >= 10

There would also need to be a way to get at txid_status() from psycopg2. If they were to support it as connection.txid_status(), you'd get this using exception_context.connection.connection.<psycopg2_api_call>.

According to this blog the tricky part is avoiding an extra round trip, sqlalchemy would need to issue BEGIN; SELECT txid_current() when flushing queries that performed a write. And issue SELECT txid_current() along with the first write if only 'SELECT's were issued

the linked article doesn't show any code and it seems (?) not even a link to documentation, so feel free to describe a code example illustrating how this would look as well as how to get this value when using psycopg2. thanks!

Here's a bit of docs https://www.postgresql.org/docs/10/functions-info.html#FUNCTIONS-TXID-SNAPSHOT

graingert

comment created time in a day

issue commentsqlalchemy/sqlalchemy

transaction traceability in pg >= 10

ensure that it can be implemented via recipe

Yes I figured this would actually be a docs change

graingert

comment created time in a day

Pull request review commentpytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

 Here's the ``equipments`` fixture changed to use ``addfinalizer`` for cleanup:     def equipments(request):         r = []         for port in ("C1", "C3", "C28"):-            equip = connect(port)-            request.addfinalizer(equip.disconnect)+            cm = connect(port)+            equip = cm.__enter__()+            request.addfinalizer(functools.partial(cm.__exit__, None, None, None))

I had a go at removing all pytest's own calls to .addfinalizer and replacing them with plain yield fixtures, and replacing it with either layered resource acquisition or an ExitStack. And it looks much nicer.

It's quite a big change, doesn't really gain anything, and I got bored half way and gave up - but it just demonstrates the superiority of the yield fixture + ExitStack approach.

graingert

comment created time in a day

Pull request review commentpytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

 Here's the ``equipments`` fixture changed to use ``addfinalizer`` for cleanup:     def equipments(request):         r = []         for port in ("C1", "C3", "C28"):-            equip = connect(port)-            request.addfinalizer(equip.disconnect)+            cm = connect(port)+            equip = cm.__enter__()+            request.addfinalizer(functools.partial(cm.__exit__, None, None, None))

I'm tempted to remove docs for addfinalizer entirely

graingert

comment created time in a day

Pull request review commentpytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

 Here's the ``equipments`` fixture changed to use ``addfinalizer`` for cleanup:     def equipments(request):         r = []         for port in ("C1", "C3", "C28"):-            equip = connect(port)-            request.addfinalizer(equip.disconnect)+            cm = connect(port)+            equip = cm.__enter__()+            request.addfinalizer(functools.partial(cm.__exit__, None, None, None))

:nauseated_face: now this is why ExitStack is so great

graingert

comment created time in a day

Pull request review commentpytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

 The ``smtp_connection`` connection will be closed after the test finished execution because the ``smtp_connection`` object automatically closes when the ``with`` statement ends. +Using the contextlib.ExitStack context manager finalizers will always be called+regardless if the fixture *setup* code raises an exception. This is handy to properly+close all resources created by a fixture even if one of them fails to be created/acquired:++.. code-block:: python++    # content of test_yield3.py++    import contextlib++    import pytest++    from .utils import connect+++    @pytest.fixture+    def equipments():

done

graingert

comment created time in a day

push eventgraingert/pytest

Thomas Grainger

commit sha a96710dd8a143c588382cc5104acd6522e7426fe

demonstrate ExitStack assuming connect returns a context manager

view details

push time in a day

issue openedsqlalchemy/sqlalchemy

transaction traceability in pg >= 10

One feature quietly added to PostgreSQL 10 is the ability to determine the commit status of any transaction by transaction-id.

https://www.2ndquadrant.com/en/blog/postgresql-10-transaction-traceability/

It should be possible to configure SQLAlchemy to check if a tx has committed with txid_status if a connection error occurs after issuing a "COMMIT" before bubbling the exception

created time in a day

PR opened bitwarden/jslib

support up to 256 char passwords

MS accounts now support up to 256 character passwords, and it's possible for companies to set a policy to raise the minimum length to 256 also

+2 -2

0 comment

1 changed file

pr created time in a day

push eventgraingert/jslib

Thomas Grainger

commit sha b1223dfc1e69fb351a75991a2efbdc218a903a1b

support up to 256 char passwords MS accounts now support up to 256 character passwords, and it's possible to companies to set a policy to raise the minimum length to 256 also

view details

push time in a day

fork graingert/jslib

Common code referenced across Bitwarden JavaScript projects.

https://bitwarden.com

fork in a day

issue commentpython/black

Long with statements are not broken into several lines

Imho most of these would look nicer with contextlib.ExitStack

mhham

comment created time in 3 days

issue openedlh3/minimap2

provide binary python wheels

created time in 4 days

delete branch graingert/sse-gateway-plugin

delete branch : pubsub-light-plugin

delete time in 4 days

PR opened jenkinsci/sse-gateway-plugin

update to pubsub-light-plugin's new name

Description

See JENKINS-XXXXX.

Submitter checklist

  • [ ] Link to JIRA ticket in description, if appropriate.
  • [ ] Change is code complete and matches issue description
  • [ ] Appropriate unit or acceptance tests or explanation to why this change has no tests
  • [ ] Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • [ ] Run the changes and verified the change matches the issue description
  • [ ] Reviewed the code
  • [ ] Verified that the appropriate tests have been written or valid explanation given
+3 -3

0 comment

1 changed file

pr created time in 4 days

create barnchgraingert/sse-gateway-plugin

branch : pubsub-light-plugin

created branch time in 4 days

fork graingert/sse-gateway-plugin

Server Sent Events (SSE) Gateway plugin for Jenkins.

fork in 4 days

issue commentjenkinsci/outbound-webhook-plugin

allow webhook subscribers to choose what to subscribe to

eg moving to a pull model rather than a push model

graingert

comment created time in 4 days

issue openedjenkinsci/outbound-webhook-plugin

allow webhook subscribers to choose what to subscribe to

currently the only way to configure outbound hooks is to

Add Outbound Webhook notification to Post-build Actions:

However devices should be able to subscribe to various events out of the box, eg with an HTTP put request

created time in 4 days

issue commentencode/http3

API design question - `Response.url`

How about instead of maintaining backwards compatibility with requests, provide a series of codemods so people can upgrade their code to the new api?

tomchristie

comment created time in 5 days

Pull request review commentpytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

 The ``smtp_connection`` connection will be closed after the test finished execution because the ``smtp_connection`` object automatically closes when the ``with`` statement ends. +Using the contextlib.ExitStack context manager finalizers will always be called+regardless if the fixture *setup* code raises an exception. This is handy to properly+close all resources created by a fixture even if one of them fails to be created/acquired:++.. code-block:: python++    # content of test_yield3.py++    import contextlib++    import pytest++    from .utils import connect+++    @pytest.fixture+    def equipments():

It's more concise in this particular case but it doesn't let you use layered resources or mix contexts and callbacks.

ExitStack would be more concise considering realistically connect will return a context manager

graingert

comment created time in 5 days

issue commentencode/http3

Retry requests

Noting here that having respect_retry_after on by default can cause a DoS attack on the HTTP client by setting excessive wait times. If it's on by default we need a reasonably short max_retry_after value.

And I'm of the opinion that having great defaults for the RetryConfig makes having an int -> total being acceptable being ever more desirable rather than less.

How about just a max_retry_after which can be set to 0 to not respect Retry-After

StephenBrown2

comment created time in 6 days

issue commentpython-http/discussions

Naming for HTTP3 / Next-Gen HTTP client library

+1 for httpx -1 for req, for the same reasons as requests3

sethmlarson

comment created time in 6 days

issue commentpytest-dev/pytest

Investigate replacing addfinalizer with ExitStack

However this is only if there's a usecase for addfinalizer that can't be replaced with a yield fixture with ExitStack

graingert

comment created time in 6 days

issue commentpytest-dev/pytest

Investigate replacing addfinalizer with ExitStack

@RonnyPfannschmidt how about exposing request.exit_stack as an instance of:

class RequestExitStack(contextlib.ExitStack):
    def pop_all(self):
        raise NotImplimentedError
``
graingert

comment created time in 6 days

issue commentpytest-dev/pytest

Investigate replacing addfinalizer with ExitStack

note: ExitStack exposes pop_all any implementation would have to remove such access

graingert

comment created time in 6 days

issue openedpytest-dev/pytest

addfinalizer can be implemented in terms of adding a callback to a stack

addfinalizer can be implemented in terms of adding a callback to a stack

it would be interesting if there was a per usage scope fixture for eexit stacks,

then each fixture could get a very own exit stack in a well expressed manner (and if each fixture had one, it wouldnt be as bad to expose it)

Originally posted by @RonnyPfannschmidt in https://github.com/pytest-dev/pytest/pull/5589#issuecomment-510082398

created time in 6 days

pull request commentpytest-dev/pytest

de-emphasize request.addfinalizer Fixes #5587

I'm not keen on deprecating/removing addfinalizer though. Are there usecases for addfinalizer that ExitStack cannot provide?

graingert

comment created time in 6 days

push eventgraingert/pytest

Thomas Grainger

commit sha c224c4f1d6aa90a20ff03aa75ed44328c843c644

de-emphasize request.addfinalizer

view details

push time in 6 days

push eventgraingert/pytest

Thomas Grainger

commit sha 27516bd2dc58fd90ca6431cfc309b2cbffc4d03b

de-emphasize request.addfinalizer

view details

push time in 6 days

PR opened pytest-dev/pytest

de-emphasize request.addfinalizer

<!-- Thanks for submitting a PR, your contribution is really appreciated!

Here is a quick checklist that should be present in PRs. (please delete this text from the final description, this is just a guideline) -->

  • [x] Target the master branch for bug fixes, documentation updates and trivial changes.
  • [ ] Target the features branch for new features and removals/deprecations.
  • [ ] Include documentation when adding new features.
  • [ ] Include new tests or update existing tests when applicable.

Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:

  • [ ] Create a new changelog file in the changelog folder, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.
  • [ ] Add yourself to AUTHORS in alphabetical order;
+50 -18

0 comment

1 changed file

pr created time in 6 days

create barnchgraingert/pytest

branch : fixture-yield-exit-stack

created branch time in 6 days

issue commentpytest-dev/pytest

exit_stack builtin fixture

or maybe we should discourage addfinalizer entirely and suggest people make their own ExitStack in a yield fixture?

@pytest.fixture
def equipments():
    with contextlib.ExitStack() as exit_stack:
        r = []
        for port in ('C1', 'C3', 'C28'):
            equip = connect(port)
            exit_stack.callback(equip.disconnect)
            r.append(equip)
        yield r
graingert

comment created time in 6 days

issue commentpytest-dev/pytest

exit_stack builtin fixture

or maybe https://docs.pytest.org/en/latest/reference.html#_pytest.fixtures.FixtureRequest could expose a .stack to be used instead of addfinalizer:

@pytest.fixture
def equipments(request):
    r = []
    for port in ('C1', 'C3', 'C28'):
        equip = connect(port)
        request.stack.callback(equip.disconnect)
        r.append(equip)
    return r
graingert

comment created time in 6 days

issue openedpytest-dev/pytest

exit_stack builtin fixture

a handy little fixture that might be worth being built in:

@pytest.fixture
def exit_stack():
    with contextlib.ExitStack() as exit_stack:
        yield exit_stack

can be used as:

def test_foo(exit_stack):
    v = exit_stack.enter_context(cm)
    some_service = Service()
    exit_stack.callback(some_service.disconnect)

created time in 6 days

issue commentpython-http/discussions

Naming for HTTP3 / Next-Gen HTTP client library

@kislyuk ^

sethmlarson

comment created time in 6 days

pull request commentfranckcuny/http

gain fcuny aproval

@fcuny can you review this PR?

graingert

comment created time in 6 days

PR opened franckcuny/http

gain fcuny aproval
+0 -1

0 comment

1 changed file

pr created time in 6 days

create barnchfranckcuny/http

branch : gain-fcuny-aproval

created branch time in 6 days

issue commentpython-http/discussions

Naming for HTTP3 / Next-Gen HTTP client library

another option is to grab the 'http' name from PyPI

/cc @fcuny (owner on pypi) @rgsoda and @ajakubek (copyright holders)

sethmlarson

comment created time in 6 days

issue openedfranckcuny/http

transfer ownership of PyPI package name and github project to python-http

It would be great to transfer this project under the python-http umbrella

https://github.com/python-http/discussions/issues/1

/cc @fcuny (owner on pypi) @rgsoda and @ajakubek (copyright holders)

created time in 6 days

push eventfranckcuny/http

Thomas Grainger

commit sha 2f3bf7b2e0bf3f9b2413f1138eeb3bc35566711a

note 'unoffical' status

view details

push time in 6 days

push eventfranckcuny/http

Thomas Grainger

commit sha e1f003147015b2731030e428cae8c88c99c45980

http 0.1 Co-authored-by: Franck Cuny <franck.cuny@gmail.com>

view details

Thomas Grainger

commit sha 56d5bacdff6a8445b883151076d18cfbc6ee7698

http 0.02 Co-authored-by: Franck Cuny <franck.cuny@gmail.com>

view details

push time in 6 days

create barnchfranckcuny/http

branch : master

created branch time in 6 days

created repositoryfranckcuny/http

http is heavily inspired by the HTTP::Message distribution.

created time in 6 days

issue commentpython-http/discussions

Naming for HTTP3 / Next-Gen HTTP client library

it would be confusing to me to make http (plaintext) requests with an https library

sethmlarson

comment created time in 6 days

issue commentencode/http3

Text streaming

having an incrementally decoding File and StreamReader like objects would be amazing contributions to the chardet project https://github.com/chardet/chardet/issues/154

tomchristie

comment created time in 6 days

issue commentencode/http3

Retry requests

I'd rather retry was an ABC and could be implemented without subclassing

StephenBrown2

comment created time in 6 days

issue commentencode/http3

API design question - `Response.url`

how about:

with http3.Session(requests_compat=True) as s:
    assert type(s.get("https://example.com").url) is str
tomchristie

comment created time in 6 days

push eventgraingert/zshrc

Thomas Grainger

commit sha e96f22dc0aee3cb23514351a1844f6c72d726066

remove linuxbrew

view details

push time in 7 days

issue commentpyenv/pyenv

add tauthon interpreter

@joshfriend regardless of whether or not "tauthon is harmful to the python ecosystem", it is just as much a valid Python 2.7 implementation as jython-2.7 or pypy2 2.7

graingert

comment created time in 7 days

issue commentgoogle/python-subprocess32

subprocess32 does not have a binary manylinux1 wheel

@gpshead it actually looks like manylinux10 support is in pip already https://github.com/pypa/pip/pull/5410

ssbarnea

comment created time in 8 days

issue commentpyenv/pyenv

add tauthon interpreter

I don't see tauthon as harmful, I'm planning on using it to help transition a code base to Python 3

graingert

comment created time in 8 days

issue openedpyenv/pyenv

add tauthon interpreter

Add tauthon

created time in 8 days

pull request commentnaftaliharris/tauthon

Implement PEP 3120 and update self-signed.pythontest.net.

Woops I was under the impression that py2 source was latin-1 by default.

The default encoding was set to "ascii" in version 2.5.

luk3yx

comment created time in 8 days

pull request commentnaftaliharris/tauthon

Implement PEP 3120 and update self-signed.pythontest.net.

I don't think this is a good idea on tauthon, which is focussed on making not breaking changes from py2.7.16.

If someone wants to use utf8 source files they can use the encoding marker comment

luk3yx

comment created time in 8 days

issue commentpytest-dev/pytest-mock

[Help wanted] Turning context mock into mocker

Read the note here about use as a context manager: https://github.com/pytest-dev/pytest-mock/blob/master/README.rst#why-bother-with-a-plugin

You're also attempting to patch an already patched object, which is kind of odd. It's better to configure the mock to be applied in your patch before application

BeyondEvil

comment created time in 11 days

issue commentpytest-dev/pytest-mock

take a detailed look at integration with the monkeypatch fixture

This to me sounds like tmp_path and tmpdir

On Fri, 5 Jul 2019, 15:26 Bruno Oliveira, notifications@github.com wrote:

@graingert https://github.com/graingert I'm not sure, because now users will have two builtin options, monkeypatch and mocker, which is confusing.

We might think about how to integrate them instead, for example monkeypatch.mock might behave like the current mocker fixture:

def test_foo(monkeypatch): monkeypatch.mock.patch('os.remove')

Or we might decide to add patch and patch.object directly to monkeypatch:

def test_foo(monkeypatch): monkeypatch.patch('os.remove')

But actually I'm leaning towards leaving outside the core for now.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pytest-dev/pytest-mock/issues/9?email_source=notifications&email_token=AADFATAP5YQCEDQMAWI7Q2DP55KZBA5CNFSM4A7URDH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZJU25A#issuecomment-508775796, or mute the thread https://github.com/notifications/unsubscribe-auth/AADFATGSJCT5UDPXP3LBIGDP55KZBANCNFSM4A7URDHQ .

RonnyPfannschmidt

comment created time in 11 days

issue commentaudreyr/cookiecutter-pypackage

`setup.py test` is bad practice

It might also be worth pyproject.toml PEP517/PEP518 support too

jamesmyatt

comment created time in 11 days

issue commentpytest-dev/pytest-mock

take a detailed look at integration with the monkeypatch fixture

@nicoddemus @RonnyPfannschmidt is this still blocking merging pytest-mock into pytest? With pytest 5 dropping support for platforms without unittest.mock it makes a lot of sense to have it built in

RonnyPfannschmidt

comment created time in 11 days

push eventgraingert/pytest

Thomas Grainger

commit sha 4a2ced9a9d7bc09d90715de3cf959bbb60b21234

add unittest compat attrs to recwarn

view details

push time in 11 days

issue commentpytest-dev/pytest-mock

[Help wanted] Turning context mock into mocker

mock_db = mocker.MagicMock()
mock_db.cursor().__enter__().fetchall.return_value = expected
mocker.patch.object(main, "_connect", cached_conn=mock_db)
BeyondEvil

comment created time in 11 days

delete branch graingert/nvidia-prime

delete branch : patch-1

delete time in 11 days

Pull request review commentpytest-dev/pytest

Handle xfail(strict=True) properly in --step-wise mode

 def pytest_collection_modifyitems(self, session, config, items):      def pytest_runtest_logreport(self, report):         # Skip this hook if plugin is not active or the test is xfailed.

This comment seems wrong

nicoddemus

comment created time in 12 days

pull request commentpytest-dev/pytest

Add exception to value alias on ExceptionInfo

@nicoddemus looks a bit like https://github.com/graingert/pytest/commit/4a2ced9a9d7bc09d90715de3cf959bbb60b21234

graingert

comment created time in 12 days

create barnchgraingert/pytest

branch : recwarn-unittest-attrs

created branch time in 12 days

pull request commentpytest-dev/pytest

Add exception to value alias on ExceptionInfo

@nicoddemus it's actually a bit of a pain as it would involve chainging how WarningsChecker works, eg it doesn't actually store the first matching warning anywhere

graingert

comment created time in 12 days

pull request commentpytest-dev/pytest

Add exception to value alias on ExceptionInfo

looking at it now

graingert

comment created time in 12 days

Pull request review commentpytest-dev/pytest

Fix pytest.raises handling of unicode exceptions in Python 2

 def match(self, regexp):         raised.         """         __tracebackhide__ = True-        if not re.search(regexp, str(self.value)):-            assert 0, "Pattern '{!s}' not found in '{!s}'".format(regexp, self.value)+        value = (+            text_type(self.value) if isinstance(regexp, text_type) else str(self.value)+        )+        if not re.search(regexp, value):+            raise AssertionError(+                u"Pattern '{}' not found in '{}'".format(regexp, value)

Done using {!r} for formatting instead, which is the safest approach I think.

I think that change will need to be ported to pytest 5

graingert

comment created time in 12 days

issue commentdebauchee/barrier

Upload package on chocolatey

https://chocolatey.org/packages?q=Barrier

graingert

comment created time in 13 days

issue openeddebauchee/barrier

Upload package on chocolatey

Please can you upload a built version of the windows package to chocolatey

created time in 13 days

issue commentpypa/setuptools

Deprecate test command

It would be good to drop sdists entirely for pure python wheels

pganssle

comment created time in 13 days

issue commentpytest-dev/pytest-runner

setup.py test is going to be deprecated

pytest no longer recommends pytest-runner. Is it a good idea to mark it for deprecation here?

graingert

comment created time in 13 days

Pull request review commentpytest-dev/pytest

remove documentation about setuptools integration Refs #5534 Fixes #3814

 against your source code checkout, helping to detect packaging glitches.  -Integrating with setuptools / ``python setup.py test`` / ``pytest-runner``

From @jaraco

Yes, I'm in favor of removing the section altogether. I don't see any value in keeping a reference to pytest-runner.

graingert

comment created time in 13 days

issue commentpytest-dev/pytest

pytest stepwise doesn't work with xfail strict failures

I expected stepwise to stop after the first XPASS(strict) failure

graingert

comment created time in 13 days

issue openedpytest-dev/pytest

pytest stepwise doesn't work with xfail strict failures

graingert@onomastic:~/projects/foo$ cat tests/test_foo.py 
import pytest


@pytest.mark.xfail(reason="pass")
def test_a():
    pass


@pytest.mark.xfail(reason="pass")
def test_b():
    pass
graingert@onomastic:~/projects/foo$ cat tests/pytest.ini 
[pytest]
addopts = --strict
xfail_strict=true
graingert@onomastic:~/projects/foo$ pytest --sw tests/
================================ test session starts ================================
platform linux -- Python 3.7.3, pytest-5.0.0, py-1.8.0, pluggy-0.12.0
rootdir: /home/graingert/projects/foo/tests, inifile: pytest.ini
collected 2 items                                                                   
stepwise: no previously failed tests, not skipping.

tests/test_foo.py FF                                                          [100%]

===================================== FAILURES ======================================
______________________________________ test_a _______________________________________
[XPASS(strict)] pass
______________________________________ test_b _______________________________________
[XPASS(strict)] pass
============================= 2 failed in 0.01 seconds ==============================

created time in 13 days

issue commentpytest-dev/pytest-runner

setup.py test is going to be deprecated

It may be worth considering what pytest-runner's place is in a PEP517/PEP518 world

graingert

comment created time in 13 days

issue openedpytest-dev/pytest-runner

setup.py test is going to be deprecated

from https://github.com/pytest-dev/pytest/issues/5534

this project also relies on setuptools options that are now considered 'smells:

    setup_requires=[
        'pytest-runner',
    ],
    tests_require=[
        'pytest',
    ],

created time in 13 days

pull request commentpytest-dev/pytest

remove documentation about setuptools integration Refs #5534

https://github.com/pytest-dev/pytest/issues/5534

graingert

comment created time in 13 days

PR opened pytest-dev/pytest

remove documentation about setuptools integration Refs #5534

integrating with python setup.py test is not good practice!

<!-- Thanks for submitting a PR, your contribution is really appreciated!

Here is a quick checklist that should be present in PRs. (please delete this text from the final description, this is just a guideline) -->

  • [ ] Target the master branch for bug fixes, documentation updates and trivial changes.
  • [ ] Target the features branch for new features and removals/deprecations.
  • [ ] Include documentation when adding new features.
  • [ ] Include new tests or update existing tests when applicable.

Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:

  • [ ] Create a new changelog file in the changelog folder, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.
  • [ ] Add yourself to AUTHORS in alphabetical order;
+0 -97

0 comment

1 changed file

pr created time in 13 days

push eventgraingert/pytest

Thomas Grainger

commit sha 2b9522e9da15107bf3a96083e0221ad6cce47bb6

remove documentation about setuptools integration Refs #5534 integrating with `python setup.py test` is not good practice!

view details

push time in 13 days

pull request commentpytest-dev/pytest

Add exception to value alias on ExceptionInfo

@nicoddemus eg aliases for all these:

https://github.com/python/cpython/blob/3.7/Lib/unittest/case.py#L248-L261

graingert

comment created time in 13 days

push eventgraingert/pytest

Thomas Grainger

commit sha bcb72ab902f73c402b149f424064d7878cdeb408

Update changelog/5541.feature.rst Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>

view details

push time in 13 days

more