Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test intents #153

Closed
pytestbot opened this issue Jun 3, 2012 · 7 comments
Closed

test intents #153

pytestbot opened this issue Jun 3, 2012 · 7 comments
Labels
type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt)


to unify various things i'd like to propose a reporting on a level of n subreports per test

the concept for that is an intent within a test

one intent should be something groups a set of operations within a context,
and decides how grave what kind of error is within that context

examples could be things like creating a certain state, working down one item of a user story or gernator test items

== example 1 - generative tests

#!python
def pytest_funcarg_call(item):
    func = item._obj
    if isgenerator(func):
        with intent(name='setup', error='fatal'):
            iter = func()

        for check in iter:
           name, func, args = split_check(check, item)
           with intent(name=name, error='report'):
               func(*args)
    else:
      func()

== example 2 - full capuring of sections

#!python

def test_subprocess(tmpdir):
   tmpdir.ensure('test')
   with intent('call', capture='fd', errors='xfail') as report
      subprocess.call(['ls'],)

   assert report.out.fnmatch_lines(['test'])

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


This more looks like an implementation idea - i have a guess what actual use cases might be like but they are not spelled out here.

@pytestbot pytestbot added the type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature label Jun 15, 2015
@nicoddemus
Copy link
Member

Could you please post more details here @RonnyPfannschmidt? 😄

@RonnyPfannschmidt
Copy link
Member

bascially the equivalent of https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests

with an addition of turning tests into sections for acceptance tests

@nicoddemus
Copy link
Member

Hmmm I see, thanks!

That seems doable, could be even be implemented as a plugin I think.

@nicoddemus
Copy link
Member

How about?

def test_foo(subtests):
    for i in xrange(5):
        with subtests:
            assert i * 2 < 5 

@RonnyPfannschmidt
Copy link
Member

A bit too minimal

Names, retrying and flakyness should be handleable as well

@RonnyPfannschmidt
Copy link
Member

closing as unactionable wishlist item, wil lcome back with something more concrete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

3 participants