Skip to content

Heavy improvements, add async yield fixture, fix bugs, add tests etc.#17

Merged
touilleMan merged 5 commits intomasterfrom
heavy-improvements
Dec 15, 2017
Merged

Heavy improvements, add async yield fixture, fix bugs, add tests etc.#17
touilleMan merged 5 commits intomasterfrom
heavy-improvements

Conversation

@touilleMan
Copy link
Member

@touilleMan touilleMan commented Dec 12, 2017

This should address #4 and #16

I'm still not happy by the fact an erroring fixture will be considered as a FAILURE instead of an ERROR (this is due to the fact the async fixture is run where the function should be run from the pytest point of view).

@touilleMan touilleMan requested a review from njsmith December 12, 2017 23:57
@codecov
Copy link

codecov bot commented Dec 13, 2017

Codecov Report

Merging #17 into master will increase coverage by 41.04%.
The diff coverage is 81.06%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #17       +/-   ##
===========================================
+ Coverage   30.76%   71.81%   +41.04%     
===========================================
  Files           5        9        +4     
  Lines          91      220      +129     
  Branches       16       18        +2     
===========================================
+ Hits           28      158      +130     
- Misses         56       61        +5     
+ Partials        7        1        -6
Impacted Files Coverage Δ
pytest_trio/_tests/test_async_yield_fixture.py 100% <100%> (ø)
pytest_trio/_tests/test_basic.py 100% <100%> (ø) ⬆️
pytest_trio/_tests/test_clock_fixture.py 100% <100%> (ø)
pytest_trio/_tests/test_async_fixture.py 100% <100%> (ø)
pytest_trio/_tests/test_sync_fixture.py 100% <100%> (ø)
pytest_trio/plugin.py 57.74% <66.66%> (+35.95%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0f8f4d...110910f. Read the comment docs.

@touilleMan
Copy link
Member Author

It seems this code trigger a core dump with Python 3.5.0 and 3.5.2 on travis:

Exception ignored in: 'garbage collection'

RuntimeWarning: coroutine 'fix1' was never awaited

ci/travis.sh: line 98:  2437 Aborted                 (core dumped) pytest -W error -ra -v --pyargs pytest_trio --cov=pytest_trio --cov-config=../.coveragerc --verbose

I cannot reproduce this behavior on my laptop with Python 3.5.2 @ ubuntu 16.04.

Funny thing is the trouble is not present with Python-3.5-dev.

My guess is travis doesn't like my use of pytester module (which allows to test a pytest environment from whithin pytest), but not sure what to do to fix this...

@njsmith
Copy link
Member

njsmith commented Dec 13, 2017 via email

@touilleMan
Copy link
Member Author

I use the testdir fixture provided by pytest to create a new pytest context (see https://github.com/python-trio/pytest-trio/pull/17/files#diff-48851f0efdd4792c878e675e38e301e1R6)

This is from this context the leaking coroutine is, so the warning issued there should not be provided to the main pytest process. The trouble is core dump cannot be ignored as easily as warnings !

Unawaited coroutines are basically always a bug.

Totally agree ! In fact the trick is this test is marked as xfail (it tests that pytest-trio should raise an error when user try to pass an async fixture with a broader scope than the default function one). Given I didn't find a clean way to do this so far, I left the test as documentation/discussion topic in the PR.

So in the end we got a xfail test leaking an async coroutine in a sub pytest environment, with warning considered as error configuration (provided to the main pytest environment) passed to the sub environment causing a core dump...

Our solutions are:

  1. remove the test (maybe take the test snippet and put it in an issue on github about adding a bad fixture scope detection feature)
  2. disable the error on warning config passed to the sub pytest environment, not sure how to do that though
  3. remove tests for python 3.5.x :trollface:

I would say 1) is the easiest

@njsmith
Copy link
Member

njsmith commented Dec 13, 2017 via email

@touilleMan
Copy link
Member Author

Issue #18 created, I've removed the test from this PR

@touilleMan touilleMan merged commit a30ffb1 into master Dec 15, 2017
touilleMan added a commit that referenced this pull request Dec 15, 2017
touilleMan added a commit that referenced this pull request Dec 15, 2017
@touilleMan touilleMan mentioned this pull request Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants